FreeMyPain Posted November 2, 2007 Share Posted November 2, 2007 I keep getting a connection error to the Mysql database.. I know that the error shows that it can't connect, the reason that's confusing me is why? I have the connection.class.php file configured correctly.. the connection is even used on the page.. with something else.. I'm doing the exact same thing as I'm doing on another page and on the other page it's working fine. The Error : Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in php/connection.class.php on line 20 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in php/connection.class.php on line 20 Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) This creates a new connection.. from my class.. $connection = new Connect(); It calls this.. function Query( $sql ) { $query = mysql_query( $sql ) or die(mysql_error()); return $query; } This is the line of code from login.php that is giving me the error : $result = $connection->Query("SELECT password FROM user_database WHERE username='$username'"); This is the line of code from create.php that is working : $result = $connection->Query("SELECT username FROM user_database WHERE username='$username'"); They both look identical to me, the code must be fine? I'm hosted with godaddy and have 5 tables in the database.. do they use different servers?(how)? If anybody can think of any reason this is happening it'll be useful.... Quote Link to comment https://forums.phpfreaks.com/topic/75731-connection-error-i-cant-for-the-life-of-me-figure-out-the-reason/ Share on other sites More sharing options...
teng84 Posted November 2, 2007 Share Posted November 2, 2007 look if theres a closing connection on that erroring page? Quote Link to comment https://forums.phpfreaks.com/topic/75731-connection-error-i-cant-for-the-life-of-me-figure-out-the-reason/#findComment-383264 Share on other sites More sharing options...
FreeMyPain Posted November 2, 2007 Author Share Posted November 2, 2007 Nope there isn't, I checked for that.. I don't know what's going on... I guess maybe I should just leave it until tomorrow, it's 3:14am and I can't think straight anyway.. little annoying thanks for the suggestion though xD Quote Link to comment https://forums.phpfreaks.com/topic/75731-connection-error-i-cant-for-the-life-of-me-figure-out-the-reason/#findComment-383277 Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 what is your mysql_connect statement in the connection class Quote Link to comment https://forums.phpfreaks.com/topic/75731-connection-error-i-cant-for-the-life-of-me-figure-out-the-reason/#findComment-383288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.