Real quick and Easy Question: What is the servername?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mirra1515
Forum Commoner
Posts: 29
Joined: Fri Apr 25, 2008 3:17 am

Real quick and Easy Question: What is the servername?

Post 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!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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.
(#10850)
User avatar
mirra1515
Forum Commoner
Posts: 29
Joined: Fri Apr 25, 2008 3:17 am

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

Post by mirra1515 »

Thank you for your response.

Yes, I am aware of that, but what would the connection string look like?
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

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

Post 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.
User avatar
mirra1515
Forum Commoner
Posts: 29
Joined: Fri Apr 25, 2008 3:17 am

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

Post 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.
Mr.RED
Forum Newbie
Posts: 8
Joined: Sat May 31, 2008 1:23 pm

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

Post 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.
Post Reply