toolman Posted October 25, 2009 Share Posted October 25, 2009 Hi, For some reason, I keep getting this error when trying to connect: Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on... Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket... Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established... This is my php code: <?php //database connection settings $db_username = "test"; $db_password = "test"; $db_host = "test"; $db_name = "test"; $connection = mysql_connect($db_username, $db_password, $db_host); if(!$connection){ echo"Cannot connect to database! Please check the settings"; } else{ echo"Database Connection Successful"; } mysql_select_db($db_name); echo"Database Connection Successful"; ?> Any ideas whats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/178969-connecion-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2009 Share Posted October 25, 2009 The three parameters in the mysql_connect() function call are not in the order that you tried. The only way to effectively use any programming language is to read the documentation for whatever small part of it you are attempting to use - http://php.net/mysql_connect Quote Link to comment https://forums.phpfreaks.com/topic/178969-connecion-issue/#findComment-944321 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.