PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Is it possible? I'm creating a script for http://www.tsnhosting.net that will connect to the MySQL server on http://www.turbosaturns.net and read the usernames and passwords from the phpbb database, but at the same time I need to pull information from a local database. Is something like this possible?
<?php
//Attempts to connect to the local MySQL server
mysql_connect('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
//Attempts to connect to the remote MySQL server
mysql_connect('remotehost', 'username', 'password') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
?>
Simple, you assign a var to each mysql_connect ($var=mysql_connect()) and then when you do a query or othe MySQL operation, add in a , and put the connection var after it
Absolutely possible, but time consuming for the user and a resource hog for all servers involved. Strongly suggest moving all data to a central, quickly accessible (i.e. the same hosting site / network as the PHP server) MySQL server.