Please help me on mysql_connect

sirSam

New Member
Messages
10
Reaction score
0
Points
0
hello guys, im a newbie in php.
i have a line of code like the following
mysql_connect("localhost",...
i uploaded my page using my account under elementfx server.
my problem is this:
Unknown MySQL server host 'Starka.x10 '
i think i should change the "localhost" to an IP address, or should really I?
I hope you can help me on here..
thanks in advance.. more power x10hosting;)
 

Silmaril

New Member
Messages
13
Reaction score
0
Points
0
Hi sam.

localhost is correct. Habe you made the database you are trying to access with your script? you should do this first in cpanel
 

sirSam

New Member
Messages
10
Reaction score
0
Points
0
hello Silmaril, thanks so much for your reply.

i already made the database using the phpMyAdmin tool from cPanel.
did i create it the wrong way? should I have used the wizard?

thanks again..
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
did you assign the user to the database the correct permissions?
 

sirSam

New Member
Messages
10
Reaction score
0
Points
0
i am getting a new error here:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'sirSam'@'localhost' (using password: YES) in...
Access denied for user 'sirSam'@'localhost' (using password: YES)
Edit:
hi leafypiggy...
i think i have not done that yet..
can you guide me pls?
 
Last edited:

Silmaril

New Member
Messages
13
Reaction score
0
Points
0
i messed my post up!

okay, mine is like this

localhost
dbname = silmaril_nuke
user = silmaril_silmaril
pass = mypass

notice the silmaril_ part......... that is cpanellogin_dblogin which makes up your complete login.

As for the permissions bit, the permissions were set up when i set up the user on mine, but i didnt use myphpadmin i used the first icon in there called MySQL Databases
 
Last edited:

sirSam

New Member
Messages
10
Reaction score
0
Points
0
i have already created the user for the database and set all the privileges
 
Messages
740
Reaction score
1
Points
18

sirSam

New Member
Messages
10
Reaction score
0
Points
0
thanks anyway Silmaril. i was so hopeless when i was waiting so your reply is already a help :)
 

Silmaril

New Member
Messages
13
Reaction score
0
Points
0
LoL thats nice of you but really, i was of no help at all but look!!! the pro's are here ;)
 

sirSam

New Member
Messages
10
Reaction score
0
Points
0
i've read your post martin, i already did those.
may i just ask, if my database is db1 and username is hello, in the function mysql_connect, should the database name parameter be "hello_db1"? or just "db1"?
Edit:
haha yeah. they're here, and... they look really so pro :)
i know the solution is now much more nearer
 
Last edited:

Silmaril

New Member
Messages
13
Reaction score
0
Points
0
i've read your post martin, i already did those.
may i just ask, if my database is db1 and username is hello, in the function mysql_connect, should the database name parameter be "hello_db1"? or just "db1"?
Edit:
haha yeah. they're here, and... they look really so pro :)
i know the solution is now much more nearer

It should be hello_db1 :happysad:

Note: This assumes that hello is your cpanel login and NOT your database login

should be;

database name "cpanellogin_dbname"
database user "cpanellogin_dblogin"

make sense?
 
Last edited:
Messages
740
Reaction score
1
Points
18
i've read your post martin, i already did those.
may i just ask, if my database is db1 and username is hello, in the function mysql_connect, should the database name parameter be "hello_db1"? or just "db1"?
Edit:
haha yeah. they're here, and... they look really so pro :)
i know the solution is now much more nearer

Your database name then will be "sirsam_db1"

Your database USER will be "sirsam_hello"

Then the password will be the one you chose.
 
Last edited:

sirSam

New Member
Messages
10
Reaction score
0
Points
0
i still get this error
Access denied for user 'sirsam_sirSam'@'localhost' (using password: YES)
:(
here is my code:
mysql_connect("LocalHost", $dbUsername, $dbPassword) or die(mysql_error());
 
Last edited:
Messages
740
Reaction score
1
Points
18
sirSam is your database user, yes? Which you made in the database area.

I'm not much of a whiz on coding.

Try mysql_connect('localhost', $dbUsername, $dbPassword) or die(mysql_error());


EDIT**:

Can you copy and paste ALL of the code you have in your index.php file.

Use [code*] PASTE YOUR CODE [/code*] (Don't use the *'s though.
 
Last edited:

sirSam

New Member
Messages
10
Reaction score
0
Points
0
Code:
<?php
$dbUserName = "sirsam_sirSam";
$dbPassword = "password removed!!";
$dbName = "sirsam_dbSirSam";
mysql_connect("LocalHost", $dbUsername, $dbPassword);// or die("Could not connect: " .mysql_error());
//mysql_select_db($dbName)or die(mysql_error());
echo "db connected, rs connected";
?>
 
Last edited by a moderator:
Messages
740
Reaction score
1
Points
18
Code:
<?php
$dbUserName = "sirsam_sirSam";
$dbPassword = "password removed!!";  [COLOR="Red"] *ADD YOUR PASSWORD BACK IN*[/COLOR]
$dbName = "sirsam_dbSirSam";
mysql_connect('localhost', $dbUsername, $dbPassword);// or die("Could not connect: " .mysql_error());
//mysql_select_db($dbName)or die(mysql_error());
echo "db connected, rs connected";
?>
 
Messages
740
Reaction score
1
Points
18
Try that code I posted but you'll need to put your password back into it?

If that doesn't work then either the database name/user area is being mixed up or the code is wrong somewhere and I have little knowledge of coding therefore can't help much more but I will look into it further - I will be gone now for around two hours so won't be able to reply.
 
Top