Jump to content

[SOLVED] 2 connections in the same script


suzzane2020

Recommended Posts

You can make multiple connections to a MySQL server in the same script, but why would you want to?  As for connecting to multiple databases, yes, you can do that to, make sure you use the optional link identifier with mysql_query().

Regards
Huggie
Why not? =)
If you are using MySQL, [b]mysql_connect[/b] function returns a MySQL link identifier.
You can use it practically in every [b]mysql_...[/b] function (see manual) as it shown below:
--
$id1 = mysql_connect(...); // first connection
$id2 = mysql_connect(...); // second connection
$query = "...";
$res1 = mysql_query($query, $id1); // perform query using first connection
$res2 = mysql_query($query, $id2); // perform query using second connection
--
Link identifier is not nessesary argument. If link_identifier isn't specified, the last opened link is assumed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.