Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

who to connect withlocal php-server to an online mysql-db??

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
hi!

i have an apache2 running locally with a php-module which works fine. what i want to do now is to connect to an online mysql-db-server (without success). do i have to have mysql installed on my system where the apache runs? which wouldn't sound very logical to me...

i just can't make a connection to the db... this is my code:

$link = mysql_connect("host", "user", "pwd")
or die("could not connect to db-server!");

i keep getting "could not connect to db-server!"...

do i need a driver for this?

cya

fag patrick.metz@epost.de
 
MySQL does not have to be installed on the same machine as the one on which Apache runs. PHP will happily connect to MySQL across a network.

The first parameter of the mysql_connect() function is the resolvable name or IP address of the server where the MySQL server is running. Does the machine you are trying to connect to have MySQL running? ______________________________________________________________________
TANSTAAFL!
 
try this (change to the real ip and stuff tho, error messages are mucho useful:

$link = mysql_connect("server_ip_address:3306", "user", "pwd");
if(mysql_errno() > 0 ){
echo &quot;<h1>Error number : &quot; . mysql_errno() . &quot;</h1><br>&quot;;
echo &quot;<b>&quot; . mysql_error() . &quot;</b>&quot;;
}else{
echo &quot;successful connection&quot;;
} ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
it works now but I had to load the page on the webspace where the mySQL-db can be found as well (using 'localhost' as hostname). no local testing on my machine possible... :-(

I think I just don't have the right hostname for connecting locally.

thanx for your ansers!

cu

frag
patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top