suzzane2020 Posted January 28, 2007 Share Posted January 28, 2007 hello,gt a doubt.(gt an interview 2mrw..need all te help)!!!!.plz helpcan we have 2 connections to the same db and like wise two connections to diff db's in te same script? Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/ Share on other sites More sharing options...
suzzane2020 Posted January 28, 2007 Author Share Posted January 28, 2007 smebody help... :-[ :-[ Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171105 Share on other sites More sharing options...
HuggieBear Posted January 28, 2007 Share Posted January 28, 2007 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().RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171108 Share on other sites More sharing options...
suzzane2020 Posted January 28, 2007 Author Share Posted January 28, 2007 ok..thnx..was asked this question in a previous interview n wasnt sure of the ans...thnx again Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171110 Share on other sites More sharing options...
Orio Posted January 28, 2007 Share Posted January 28, 2007 Another thing- when you run your queries (mysql_query()), supply the optional connection parameter to avoid confusion and errors.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171112 Share on other sites More sharing options...
Roman Lubimov Posted January 28, 2007 Share Posted January 28, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171114 Share on other sites More sharing options...
suzzane2020 Posted January 28, 2007 Author Share Posted January 28, 2007 thnx a lot for all your help guys... :) Quote Link to comment https://forums.phpfreaks.com/topic/36055-solved-2-connections-in-the-same-script/#findComment-171115 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.