LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   MYSQL problems with nested connection (https://www.linuxquestions.org/questions/programming-9/mysql-problems-with-nested-connection-44135/)

saravanan1979 02-04-2003 11:03 PM

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

moeminhtun 02-05-2003 01:51 AM

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);

saravanan1979 02-05-2003 02:26 AM

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

moeminhtun 02-05-2003 02:39 AM

Are you opening multiple connections to the same database? Or one connection for one database?

saravanan1979 02-05-2003 02:42 AM

Multiple conncections to one database

moeminhtun 02-05-2003 02:51 AM

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);

saravanan1979 02-05-2003 02:53 AM

What if i pass the new link parameter every time will it bother me??

moeminhtun 02-05-2003 02:59 AM

I don't think so. Everytime it will create the new link.

saravanan1979 02-05-2003 03:13 AM

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

moeminhtun 02-05-2003 03:23 AM

:)
Welcome.
Well i'm not a php developer, but a java developer. (currently)

saravanan1979 02-05-2003 06:59 AM

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??

moeminhtun 02-05-2003 07:05 AM

The "new_link" parameter only available in PHP 4.2.0 onwards.

saravanan1979 02-05-2003 07:10 AM

sorry
 
Oh regrets for misunderstaNDING..i USER PHP 4.04pl1,anywayz are u from Singapore

moeminhtun 02-05-2003 07:12 AM

Oh..ic. Too bad.
Yes i am from singapore.

saravanan1979 02-05-2003 07:20 AM

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.