how to link external databases using mysql?
hello...i'm design a web site on my local web server but my database is at another site, i know how to use mysql which link to local web server but got no idea how to link it to external database...anyone has this kind of experience?
here is script tat i used to connect to my local database: <?php $db_connection = mysql_connect("localhost", "", "") or die("Could not connect to DB"); mysql_select_db("wsr", $db_connection) or die("Could not find DB"); $query = mysql_query("select * from cgi", $db_connection); while($data = mysql_fetch_object($query)) { print ("$data->name" ."<br>"); } mysql_close($db_connection); ?> |
Just change this line:
PHP Code:
PHP Code:
|
i try tat already but won't work and come out the warming like below:
Warning: mysql_connect(): Unknown MySQL Server Host "ITS.com' (2) in /var/www/html/mysql.php on line 2 Could not connect to DB |
You can also try this format -
Code:
hostname:port If you don't succeed then contact your administrator for help. |
Also take a look at the mySQL documentation. Particularly at the GRANT stuff. You'll note that creating a login/password isn't necessarily enough. You may need to create a login/password that works from any hostname.
|
i got it, thks a lot!
it can't connect b'cos of the host permission on database center there has not been set...so after i ask for help from support at center there then i able to connect the database. thks again all of u! |
All times are GMT -5. The time now is 02:18 AM. |