Say a friend has a MySQL database and agrees to let me access it from my server. I want to have my own set of PHP files, but use his database’s data
Shouldn’t this be possible?
In my trial, I think the MySQL access info is correct – ie. I just changed the host_name to the actual “http:” prefixed URL, nothing else should change. What about db_user?
Any ideas or directions to resources that might help?
So it seems that my domain name is being appended to the MySQL user login name. So naturally, it will fail when trying to access my friend’s mysql account.
Can I work around this? I’ve tried forcing my friend’s domain on the login, but no dice
Is there another way for PHP to access a remote MySQL database?
What we want to do is have two distinct front-ends, that access the same database.
My friend, “M”, has a working PHP script that accesses a MySQL database in Chicago. I would like my server, “A”, to have my own set of files here in Taipei. M can design his pages any way he likes, and i can design A anyway I like. But the underlying data is the same.
Maybe the “http://” is the problem. It doesn’t seem necessary. Also, do you perhaps need a port number?
$hostname = "mysql.snake.net:3307";
if (!($conn_id = @mysql_connect ($hostname, "cbuser", "cbpass")))
die ("Cannot connect to server\n");
You also might want to investigate whether there’s a performance difference between mysql_connect() and mysql_pconnect(), with the latter not closing the connection at the end of the script.