MySQL connection issue in PHP


I’m working on a site for a client and discovered that my php version is (was) 5.2.3 and theirs is 4.3.7. I downgraded my php version to 4.4.7 to be more compatible with their system and adjust my code accordingly. Things were working fine for awhile, but now I’m getting these errors on my php page:

Warning: mysql_query() [function.mysql-query]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) in /home/.bodacious////login.php on line 50

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/.bodacious////login.php on line 50

I’m not sure if this is a database issue, a php versioning issue, or a coding issue. I’ve submitted a support ticket, but I was wondering if anyone here might have an idea if it’s ME (which could be very likely ;-)…or something else on the server side.



How did you connect to MySQL server?

Are you using MySQL socket or Hostname:Port?

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


I’ve always used a connection file…something like this:
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn)
die('Could not connect: ’ . mysql_error());

mysql_select_db($dbname, $conn);


which $dbhost is the hostname of your MySQL server like “” right?

Can you try

  1. double check your MySQL database via DH panel --> Goodies --> Manage MySQL. Make sure your database is listed there.
  2. write a simple sql query to retrieve some data from the database.

If it still failed to connect to database, we shall wait for the support to solve the problem.

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


Yes, I checked the db in the control panel and logged into phpMyAdmin and queried before the panic attack and post for help :wink: I even checked my other apps to make sure it wasn’t a system-wide problem. I’m thinking now my code is WAY out of sync with the lower version of php. I shall wait to see what support says and start recoding…it’s gonna be a long night.

Thanks for your help!


$conn = mysql_connect($dbhost, $dbuser, $dbpass);

I don’t see any problem running this script with PHP4. Let’s see what support says.

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


Support said the same things we did…but somehow it’s magically fixed :slight_smile: