The Little Guy Posted December 21, 2010 Share Posted December 21, 2010 When I try to connect to my database I am getting this error: Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\Envne\envne.com\mysqlAdmin\classes\Database.php on line 9 Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is kn (trying to connect via tcp://root:3306) in C:\wamp\www\Envne\envne.com\mysqlAdmin\classes\Database.php on line 9 Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\Envne\envne.com\mysqlAdmin\classes\Database.php on line 9 Here is the EXACT code on line 9: mysql_connect('root', '', 'localhost'); I have never gotten this error before... how do I fix it? Quote Link to comment https://forums.phpfreaks.com/topic/222312-mysql_connect-and-php_network_getaddresses/ Share on other sites More sharing options...
mattal999 Posted December 21, 2010 Share Posted December 21, 2010 It's trying to connect to tcp://root:3306/, which is incorrect. mysql_connect('localhost', 'root', ''); // Function declaration: mysql_connect($host, $user, $pass); Quote Link to comment https://forums.phpfreaks.com/topic/222312-mysql_connect-and-php_network_getaddresses/#findComment-1149963 Share on other sites More sharing options...
PFMaBiSmAd Posted December 21, 2010 Share Posted December 21, 2010 It would probably be a good idea for you to read the documentation for mysql_connect(). The first parameter is the host name/ip of the mysql server. Quote Link to comment https://forums.phpfreaks.com/topic/222312-mysql_connect-and-php_network_getaddresses/#findComment-1149964 Share on other sites More sharing options...
The Little Guy Posted December 21, 2010 Author Share Posted December 21, 2010 oh wow... I feel dumb now... I have used that function hundreds of times, and I put the host in the wrong spot Sorry, but thanks guys for pointing that out! Quote Link to comment https://forums.phpfreaks.com/topic/222312-mysql_connect-and-php_network_getaddresses/#findComment-1149974 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.