Ezio Posted October 22, 2013 Share Posted October 22, 2013 Hey guys, here is the problem that i am having, i am connecting to the server using these lines: $link = mysql_connect('localhost', 'username', 'password');if (!$link) { die('Not connected : ' . mysql_error());} it shows the following error: Not connected : No connection could be made because the target machine actively refused it. what am i doing wrong..?? Link to comment Share on other sites More sharing options...
Ingolme Posted October 22, 2013 Share Posted October 22, 2013 I'm looking this up on Google and maybe changing localhost to 127.0.0.1 will fix the problem. Link to comment Share on other sites More sharing options...
Ezio Posted October 24, 2013 Author Share Posted October 24, 2013 Yes, that worked. But isn't localhost the same as 127.0.0.1 ? Link to comment Share on other sites More sharing options...
Ingolme Posted October 24, 2013 Share Posted October 24, 2013 Only if the windows hosts file says it is. It seems if you're running the server in a virtual box or sometimes simply because the hosts file got manipulated localhost might not be pointing to 127.0.0.1. You can search online about the windows hosts file if you want to learn more about it. With that file you can assign names to any IP address. Link to comment Share on other sites More sharing options...
Ezio Posted October 24, 2013 Author Share Posted October 24, 2013 (edited) That means instead of "localhost" i should write the ip address of my database, whatever it might be..?? (so should that be the practice, writing the ip instead of localhost). Edited October 24, 2013 by Ezio Link to comment Share on other sites More sharing options...
Ingolme Posted October 24, 2013 Share Posted October 24, 2013 Localhost means 127.0.0.1, so that's the IP of your database. Link to comment Share on other sites More sharing options...
Ezio Posted October 25, 2013 Author Share Posted October 25, 2013 Localhost means 127.0.0.1, so that's the IP of your database. so should that be the practice from now on, writing the ip instead of localhost..?? Link to comment Share on other sites More sharing options...
Ingolme Posted October 25, 2013 Share Posted October 25, 2013 I always use localhost, myself. It's just something wrong with your Windows hosts file. Though writing the IP address rather than localhost will certainly ensure there are no domain name errors. Link to comment Share on other sites More sharing options...
Ezio Posted October 28, 2013 Author Share Posted October 28, 2013 Thanks a lot. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now