Please Help! Can't connect to remote MySQL server using PHP

Hello,

I am trying to connect to a remote mysql server through php. Here's the
code:

mysql_connect("my.hostname.edu", "username", "password") or die
(mysql_error());
mysql_select_db("db_name") or die ("unable to select
db".mysql_error());
$r1 = mysql_query('SELECT * FROM table') ;

Using the mysql prompt on the remote server, the mysql -h -u -p works
just fine with the parameters i've specified here. According to the
user table I have the proper permissions. I just can't figure out what
could be preventing the connection here, although I am no expert...can
anyone help?!

BTW, I am using PHP 4.4.1 and mysql 5.0.

Thanks in advance...
courtney.machi [ Di, 23 Mai 2006 22:07 ] [ ID #1329724 ]

Re: Please Help! Can't connect to remote MySQL server using PHP

Hello,
In my opinion good method to conect to the mysql server is:

<?
$my=mysql_connect("IP_or_domain","user","password");
mysql_select_db("database_name",$my);
?>

It works propertly. I'm using Apache 2.2 , mySQL 4.3 and PHP 4 & 5
good luck.


Uzytkownik <courtney.machi [at] gmail.com> napisal w wiadomosci
news:1148414860.313147.325630 [at] j73g2000cwa.googlegroups.com.. .
> Hello,
>
> I am trying to connect to a remote mysql server through php. Here's the
> code:
>
> mysql_connect("my.hostname.edu", "username", "password") or die
> (mysql_error());
> mysql_select_db("db_name") or die ("unable to select
> db".mysql_error());
> $r1 = mysql_query('SELECT * FROM table') ;
>
> Using the mysql prompt on the remote server, the mysql -h -u -p works
> just fine with the parameters i've specified here. According to the
> user table I have the proper permissions. I just can't figure out what
> could be preventing the connection here, although I am no expert...can
> anyone help?!
>
> BTW, I am using PHP 4.4.1 and mysql 5.0.
>
> Thanks in advance...
>
Mariusz Jedrzejko [ Di, 23 Mai 2006 23:03 ] [ ID #1331138 ]
PHP » alt.php.sql » Please Help! Can't connect to remote MySQL server using PHP

Vorheriges Thema: excluding...
Nächstes Thema: 2 statements in to 1