fuzz_pucker Posted November 14, 2011 Share Posted November 14, 2011 Hi. I am having trouble with the mysql_connect function. When I try it I get the "Can't get hostname for your address" error. I have enabled skip-name-resolve on my mySQL server, and I am positive this error has something to do with PHP, not the mySQL server because this works from the EasyPHP, but not my actual web server. Here are the details: MySQL server: OS: Windows 7 IP: 192.168.0.188 Port: 3306 Version: 5.5.8 skip-name-resolve is in the my.ini configuration file under [mysqld], as it should be. remote connections are enabled, and work from other machines. PHP connecting client: OS: Ubuntu Server 10.04.3 IP: 192.168.0.198 Apache Version: 2.2.14 PHP version: 5.3.2-1ubuntu4.10 with Suhosin-Patch (cli) Code: <?php $con = mysql_connect("192.168.0.188:3306","root","password"); if (!$con) { die('Cant Connect: ' . mysql_error()); } ?> That code is saved in a .php file as test.php. When I visit it from my PC's version of EasyPHP (5.3.8.0) everything works fine, but when I visit the same page when its hosted on my Ubuntu server, I get "Could not connect!: Can't get hostname for your address". I just need my Ubuntu server to be able to connect to the mySQL server with PHP. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/251125-cant-get-hostname-for-your-address/ Share on other sites More sharing options...
QuickOldCar Posted November 14, 2011 Share Posted November 14, 2011 try using localhost instead $con = mysql_connect('localhost','root','password'); or even $con = mysql_connect('example.com:3306','root','password'); or $con = mysql_connect('127.0.0.1:3306','root','password'); Link to comment https://forums.phpfreaks.com/topic/251125-cant-get-hostname-for-your-address/#findComment-1288141 Share on other sites More sharing options...
fuzz_pucker Posted November 14, 2011 Author Share Posted November 14, 2011 Hi! Thanks for your reply. It works fine from the Ubuntu server when I connect to localhost using '127.0.0.1' OR 'localhost' with or without the port. Still won't work when I try to connect to the remote MySQL server though. Any Ideas? P.S. How do I disable the verification question? Incredibly annoying. Link to comment https://forums.phpfreaks.com/topic/251125-cant-get-hostname-for-your-address/#findComment-1288148 Share on other sites More sharing options...
fenway Posted November 15, 2011 Share Posted November 15, 2011 Verification question? That's not a mysql thing. Link to comment https://forums.phpfreaks.com/topic/251125-cant-get-hostname-for-your-address/#findComment-1288199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.