Page 1 of 1

Real quick and Easy Question: What is the servername?

Posted: Thu May 29, 2008 11:55 pm
by mirra1515
I have been using the localhost and had great success; however, I am now using a web domain.

I am used to using the following connection command:

$con = mysql_connect("localhost","username","password");

What would it be if my web domain was "www.mysite.com"?

Would it be:

$con = mysql_connect("www.mysite.com","username","password");

Real simple question, but I have had no luck, so thank you for any help!

Re: Real quick and Easy Question: What is the servername?

Posted: Fri May 30, 2008 1:50 am
by Christopher
The name 'localhost' is how you refer to the server on which the application is running. Domain names like you show are for referencing other servers.

Re: Real quick and Easy Question: What is the servername?

Posted: Fri May 30, 2008 9:13 am
by mirra1515
Thank you for your response.

Yes, I am aware of that, but what would the connection string look like?

Re: Real quick and Easy Question: What is the servername?

Posted: Fri May 30, 2008 9:33 am
by nowaydown1
You should check with your webhost. Look through their FAQ pages. They normally have information available about the database hostname that you should connect to. It might be localhost, or it might be somethink like 'db1.somehost.com'. Every hosting provider will be different.

Re: Real quick and Easy Question: What is the servername?

Posted: Fri May 30, 2008 11:59 pm
by mirra1515
Thank you all for your posts! I simply was of the impression that "localhost" was only for your personal computer. Apperantly, it works on the web too...go figure...never would have guessed.

Re: Real quick and Easy Question: What is the servername?

Posted: Sat May 31, 2008 1:47 pm
by Mr.RED
Yes it would remain localhost as normal webhosts have the sql server on the same server; its only when its a seperate server do you have to specify something other than localhost.