LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-04-2003, 11:03 PM   #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-04-2003 at 11:04 PM.
 
Old 02-05-2003, 01: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 02:07 AM.
 
Old 02-05-2003, 02: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, 02: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, 02:42 AM   #5
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
Multiple conncections to one database
 
Old 02-05-2003, 02: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, 02: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, 02: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 03:01 AM.
 
Old 02-05-2003, 03: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, 03: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, 06: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, 07: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, 07: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, 07: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, 07: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



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 01:41 AM
Mysql Remote Connection Problems harbringer Linux - Software 5 04-14-2005 02:42 PM
gSOAP problems with nested functions Mq2004 Programming 0 03-27-2005 04:26 AM
Mysql Error: Lost Connection to Mysql during query ramnath Programming 5 11-18-2003 12:27 PM
Mysql/Apache Connection problems... amish_geek Linux - Software 2 02-12-2003 10:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:30 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration