Take the 2-minute tour ×

what does happen if I use multiple mysql_connect() to the same mysql server? I use this function in some functions and call mysql_close() inside one of them and it cause the other connections be closed too.

How can I resolve it?

share|improve this question
dude, you accepted the wrong answer. –  Your Common Sense Feb 8 '12 at 10:06
@Col. Shrapnel: and because of that use give me -1 point? we need to do multiple connection sometimes. My question was a question about connection concept. –  hd. Feb 16 '12 at 9:35
It is not true. Your question was not about "concept" but about wrong connection usage in your code. For the code from your question you don't need multiple connections at all. Once you will need it - you are welcome to ask it. –  Your Common Sense Feb 16 '12 at 10:04
add comment

4 Answers

up vote 0 down vote accepted

open the mysql connection with an identifier, for example:

$connection1 = mysql_connect('server','user','password');

$connection2 = mysql_connect('server','user','password');

this will only close $connection1;

share|improve this answer
add comment

Just don't use multiple connects.
Connect once, then run your functions and then call mysql_close once (not necessary)

share|improve this answer
add comment

Declare a variable in which the NewLink will be stored.

    if (!$link) {
    echo 'Connected successfully';



share|improve this answer
add comment
 bool mysql_close  ([ resource $link_identifier  ] )



Check this reference :http://in2.php.net/manual/en/function.mysql-close.php

share|improve this answer
hello this is the useful content for this question ! why do you click as not useful ! it actually helps someone not for yours. –  Sam Arul Raj Feb 8 '12 at 8:29
add comment

Your Answer


