11-06-2009, 06:52 AM
|
#2 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 65
Thanks: 0
|
I am more familiar with MySQL than MSSQL but I have dabbled in several databases in PHP. So what I do know is that you can connect to multiple MySQL databases by using the link_identifier parameter in the mysql_query() function and it appears that mssql_query() has a link_identifier parameter as well.
Now the technique that vBulliten is using is a bit more complex and so here I will just give a simplified example
PHP Code:
$location = 'localhost';
$database = 'mydb';
$username = 'userid';
$password = 'userpass';
$open_db = mysql_connect($location, $username, $password);
if (!$open_db) die ('Could not connect MySQL');
mysql_select_db($database, $open_db) or die ('Could not open database');
$qry = "
SELECT *
FROM `MyTable`
";
$results = mysql_query($qry, $open_db) or die(mysql_error());
In the above example note the use of "$open_db" variable in the mysql_query function.
|
|
|
|