469,148 Members | 1,297 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,148 developers. It's quick & easy.

Query on MSQL

Im trying to use the mysql_connect command to connect to the mysql
server from a php file.

What is the HOST name I should use?

The tutorial book I have uses "localhost" but Im installing the file
live on the internet, not on a local host machine on pc.

(There are 3 parameters given --- hostname, username, userpassword.).

thank you for any help.

May 16 '06 #1
11 1395
re**************@yahoo.co.in wrote:
Im trying to use the mysql_connect command to connect to the mysql
server from a php file.

What is the HOST name I should use?


Usually it is localhost. If it is something else, it is something like
server.address.com or 192.168.0.1. But if your service provider didn't
provide you any host address, then it is most likely localhost. If it
isn't, then we have no way knowing what it is and you need to ask that
from your service provider.
May 16 '06 #2
re**************@yahoo.co.in wrote:
Im trying to use the mysql_connect command to connect to the mysql
server from a php file.

What is the HOST name I should use?


Oh, and in case that wasn't obvious to you, the host name is the address
of the machine where MySQL server is running (as you might know you can
contact to server that is located on another computer than where your
php script is running).
May 16 '06 #3
re**************@yahoo.co.in wrote:
Im trying to use the mysql_connect command to connect to the mysql
server from a php file.

What is the HOST name I should use?

The tutorial book I have uses "localhost" but Im installing the file
live on the internet, not on a local host machine on pc.


Use the hostname (or IP address) of the host running MySQL.

If MySQL and your PHP scripts run on the same host, you can use the
conventional alias "localhost".

The alias "localhost" means the same host which is initiating the
connection. Not necessarily the host that is local to _you_.

Regards,
Bill K.
May 16 '06 #4
Thank you.

Ive tried 'localhost' and the address of the web site. The php program
still comes up with message "cant connect to server"

you cant write a meaningfull php program wo access to mysql.

May 16 '06 #5
re**************@yahoo.co.in wrote:
Im trying to use the mysql_connect command to connect to the mysql
server from a php file.


Are you sure that there even is a mysql server? Where did you find out
that there is one and what the username and password and database name
are for it? The page/mail that claims there is one, should have more
info about what parameters to use to connect it.
May 16 '06 #6
:-0)

well I setup the database myself -- thats kind of how I know the
username password.

Not sure what variable to put for parameter "host".

Much more difficult to work in isolation than as a member of a team.

May 16 '06 #7
re**************@yahoo.co.in wrote:
Ive tried 'localhost' and the address of the web site. The php program
still comes up with message "cant connect to server"


I agree with Aggro -- find out from whomever manages the server host in
question if MySQL is actually running. This is the first
troubleshooting step.

Regards,
Bill K.
May 16 '06 #8
re**************@yahoo.co.in wrote:
well I setup the database myself -- thats kind of how I know the
username password.

Not sure what variable to put for parameter "host".


In that case you should know the answer. Is the database server and php
files on the same computer or on two different computers?
May 17 '06 #9
problem sorted. Problem with programming is usually the manual is
arcane, and you can go round and round for hours trying to sort a
simple problem -- easier to get help from your peers :0==)

May 18 '06 #10
re**************@yahoo.co.in wrote:
problem sorted. Problem with programming is usually the manual is
arcane, and you can go round and round for hours trying to sort a
simple problem -- easier to get help from your peers :0==)


I'm curious, what was wrong and what was the solution?
May 18 '06 #11
I was using the username for the php server rather than the username
for the mysql server. You can spend hours and hours going round a
problem like this.

May 19 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
reply views Thread by anthony | last post: by
2 posts views Thread by chazzy69 | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.