Jump to content

Error while connecting to mysql on server


Ezio

Recommended Posts

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

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

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 by Ezio
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...