Cant connect to MySQL any more
Posted by: pr0fess0r
Posted on: 2007-01-07 13:20:00
Hi
I have a Smarty-based site on propel.dreamhost.com and today I'm finding a blank page... turning on smarty debugging I get
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.nittany/beezkneez/(mywebsite)/classes/db.class.php on line 40
I can connect to phpMyAdmin fine, and in my smarty config I have the correct values for host, username, password and database name (and I'm not using localhost for the MySQL hostname). I havent changed anything code-wise over Christmas.
I wonder if it's an environment thing though because line 2 of the error is:
"Could not connect to"
with no server name specified.
The Smarty line in db.class.php is
$sqllink = mysql_connect ($server, $username, $password) or die ("Could not connect to $servern");
This is called from index.php:
$root = "";
require($root."config.php");
require $root.'libs/Smarty.class.php';
include($root."classes/db.class.php");
$db = new DB();
$sqllink = $db->connect($sqlhost, $sqlusername, $sqlpassword);
$db->use_db($sqldatabase);
I thought I would try setting the $root variable, to
/home/beezkneez/(mywebsite)/
.. no luck. Also, if I manually add the server/username/pass to the db.class.php connection code I then get the error:
Fatal error: Cannot instantiate non-existent class: db in /home/.nittany/beezkneez/(mywebsite)/index.php on line 29
I get this error even if I set the $host variable, so the include line
include($root."classes/db.class.php");
should work. And classes/db.class.php does exist.
Is this a problem with the server? Can anyone suggest other things to check?
cheers
Lucas