aaronrb Posted March 19, 2006 Share Posted March 19, 2006 Hi all, i really aint got a clue what is going on, i have used this code a hundred times before but i don't think it likes my new host. [a href=\"http://aaron.awardspace.co.uk/home.php\" target=\"_blank\"]an example is here [/a]i get this error message everything time: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/aaron.awardspace.co.uk/db_connect.php on line 10Couldn't connect to server.[/quote]and here is my simple to use code:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?//mysql$host = "localhost";$username = "username";$password = "password";$database_name = "tkd1987_aaron";//databsae connection.$connection = mysql_pconnect("$host","$username","$password") or die ("Couldn't connect to server."); $db = mysql_select_db("$database_name", $connection) or die("Couldn't select database.");?>[/quote]Sorry for being a pain if this is just some stupid reading error.but thanks in advance anyway.Aaron Quote Link to comment https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/ Share on other sites More sharing options...
blazing_bruce Posted March 19, 2006 Share Posted March 19, 2006 hello, mysql_pconnect(); function for connecting mysql server. if you are using a simple database on your website then use mysql_connect(); it is enough.Thank you,Karthi keyan. Quote Link to comment https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/#findComment-18864 Share on other sites More sharing options...
aaronrb Posted March 19, 2006 Author Share Posted March 19, 2006 [!--quoteo(post=356475:date=Mar 19 2006, 08:09 PM:name=blazing_bruce)--][div class=\'quotetop\']QUOTE(blazing_bruce @ Mar 19 2006, 08:09 PM) [snapback]356475[/snapback][/div][div class=\'quotemain\'][!--quotec--]hello, mysql_pconnect(); function for connecting mysql server. if you are using a simple database on your website then use mysql_connect(); it is enough.Thank you,Karthi keyan.[/quote]thanks but i have tried that too and i still get the same error!! Quote Link to comment https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/#findComment-18868 Share on other sites More sharing options...
blazing_bruce Posted March 19, 2006 Share Posted March 19, 2006 hello,The error Can't connect to ... normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket filename or TCP/IP port number when trying to connect to the server. for more reference about these type of probs [a href=\"http://www.oscommerce.info/kb/osCommerce/General_Information/Common_Problems/69\" target=\"_blank\"]http://www.oscommerce.info/kb/osCommerce/G...mon_Problems/69[/a]Thank you,Karthi keyan. Quote Link to comment https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/#findComment-18887 Share on other sites More sharing options...
shortj75 Posted March 20, 2006 Share Posted March 20, 2006 i had the same problem i had to remove all the variables for some reason that i do not know it just wouldnt read them the connect code i use now looks like this[code]<?mysql_pconnect('localhost', 'username', 'password') or die ("Couldn't connect to server.");mysql_select_db('tkd1987_aaron')or die("Couldn't select database.");?>[/code]that is the only way i could get mine to connecthopfully this helps Quote Link to comment https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/#findComment-19084 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.