LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2003, 12:03 AM   #1
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Rep: Reputation: 30
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

Last edited by saravanan1979; 02-05-2003 at 12:04 AM.
 
Old 02-05-2003, 02:51 AM   #2
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
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);

Last edited by moeminhtun; 02-05-2003 at 03:07 AM.
 
Old 02-05-2003, 03:26 AM   #3
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
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
 
Old 02-05-2003, 03:39 AM   #4
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
Are you opening multiple connections to the same database? Or one connection for one database?
 
Old 02-05-2003, 03:42 AM   #5
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
Multiple conncections to one database
 
Old 02-05-2003, 03:51 AM   #6
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
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);
 
Old 02-05-2003, 03:53 AM   #7
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
What if i pass the new link parameter every time will it bother me??
 
Old 02-05-2003, 03:59 AM   #8
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
I don't think so. Everytime it will create the new link.

Last edited by moeminhtun; 02-05-2003 at 04:01 AM.
 
Old 02-05-2003, 04:13 AM   #9
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
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
 
Old 02-05-2003, 04:23 AM   #10
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30

Welcome.
Well i'm not a php developer, but a java developer. (currently)
 
Old 02-05-2003, 07:59 AM   #11
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
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??
 
Old 02-05-2003, 08:05 AM   #12
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
The "new_link" parameter only available in PHP 4.2.0 onwards.
 
Old 02-05-2003, 08:10 AM   #13
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
sorry

Oh regrets for misunderstaNDING..i USER PHP 4.04pl1,anywayz are u from Singapore
 
Old 02-05-2003, 08:12 AM   #14
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
Oh..ic. Too bad.
Yes i am from singapore.
 
Old 02-05-2003, 08:20 AM   #15
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
Ok any methods of hetting out if this problem in versions<4.1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql and mysql java connector, connection refused arubin Slackware 3 03-29-2008 02:41 AM
Mysql Remote Connection Problems harbringer Linux - Software 5 04-14-2005 03:42 PM
gSOAP problems with nested functions Mq2004 Programming 0 03-27-2005 05:26 AM
Mysql Error: Lost Connection to Mysql during query ramnath Programming 5 11-18-2003 01:27 PM
Mysql/Apache Connection problems... amish_geek Linux - Software 2 02-12-2003 11:48 AM


All times are GMT -5. The time now is 03:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration