mysql_connect error

Status
Not open for further replies.

jerome1g

Member
Messages
113
Reaction score
1
Points
18
When I try to connect to the database I get the following error:

Unknown MySQL server host ' xo3.x10hosting.com' (4)

My dbconfig.php looks likes this:
<?php
$conn = mysql_connect('xo3.x10hosting.com', 'dbusername', 'dbpassword');
What should the sever name be ^

mysql_select_db('dbname');
?>

Thank You
 

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
Did you try 'localhost' ?
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
I changed my connect around. It now reads:

$conn = mysqli_connect('localhost',
'my_user',
'my_password',
'my_db') or die(mysqli_error());
In addition I think I had the database name as part of my user so I removed that.
I seem not to getting the connect error messages any more.

Thank You to all that have helped me.
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Even though this seems to be resolved with the most appropriate solution, I should point out that the other issue with the script in the OP is to do with not providing a connection to mysql_select_db().
For future reference, connections stored in variables should also be put into functions such as mysqli_real_escape_string(), mysqli_close() and mysqli_query() (mysqli_num_rows and mysqli_fetch_assoc already use the results from mysqli_query so you don't need to give it any connection).
 
Last edited:
Status
Not open for further replies.
Top