MYSQL problems with nested connection
Hello All
I basically develop application using PHP.MYSQl on Linux.The proble i face with MYSQL is if i open multiple Mysql connectins using my php script eg: mysql_connect() Some Code mysql_connect() Some Code mysql_close() Some Code mysql_close() The problem i face in the above is when i close the inner connection the external conncetion also gets closed..Can any one tell me what setting i have to do to avoid this problem Regards Saravanan |
I think you have to use the link identifier for each connection so that you could close the specified connection you wanna close. For example,
$link = mysql_connect("localhost", "mysql_user", "mysql_password") mysql_close($link); |
yes i do it in that manner, i have just given u an example .But it works fine in one server but it another server it gives me a problem
Saravanan |
Are you opening multiple connections to the same database? Or one connection for one database?
|
Multiple conncections to one database
|
Then you need to specified the "new link" parameter for the second connection. Did you ?
If a second call is made to mysql_connect() with the same arguments and you don't specified "new link" parameter, then the link identifier of the already opened link will be returned. ("new link" parameter is a boolean value after the Password parameter) For example, $link = mysql_connect("localhost", "mysql_user", "mysql_password") $link2 = mysql_connect("localhost", "mysql_user", "mysql_password", true) mysql_close($link2); |
What if i pass the new link parameter every time will it bother me??
|
I don't think so. Everytime it will create the new link.
|
Okay thanks a lot for your reply.I will try the same and get back to you.Are u a PHP developer working in Singapore how i PHP market there,I am PHP developer in Chennai
Saravanan |
:)
Welcome. Well i'm not a php developer, but a java developer. (currently) |
I am sorry to say mysql_connect receives only 3 parameters not more than 3 so i do know wther the option 4th parameter has worked fro you or not??
|
The "new_link" parameter only available in PHP 4.2.0 onwards.
|
sorry
Oh regrets for misunderstaNDING..i USER PHP 4.04pl1,anywayz are u from Singapore
|
Oh..ic. Too bad.
Yes i am from singapore. |
Ok any methods of hetting out if this problem in versions<4.1
|
All times are GMT -5. The time now is 10:25 PM. |