From:             [EMAIL PROTECTED]
Operating system: SuSE Linux 7.0
PHP version:      4.0.4
PHP Bug Type:     MySQL related
Bug description:  closed mysql connection after calling a function that uses another 
mysql conn.

in file functions.inc:

function func1($blabla) {
   $conn = mysql_connect ("host","user","pass");
   mysql_select_db("db",$conn);
   $resset=mysql_query("SELECT a,b,c FROM ATable",$conn);
   mysql_close($conn); 
}

-------------------

file index.php:
include ("functions.inc");

$conn_main = mysql_connect ("host","user","pass");
mysql_select_db("db",$conn_main);

$resset=mysql_query("SELECT a,b,c FROM ATable",$conn_main); <-- this statement works 
and returns a result
func1($abc); <-- call defined function
$resset=mysql_query("SELECT a,b,c FROM ATable",$conn_main); <-- after calling the 
above defined function i get an error: warning: 1 is not a valid mysql link resource

mysql_close($conn_main); 

so thats the problem:
i have a script that makes a mysql connection. i can select, update, insert aso. from 
the db. then i call a function that itself makes a connection to the same db, does 
something with it (works fine) closes the connection and returns. i dont use global or 
give the main connection as an argument, its just a plain standalone function. after 
calling the function the main script has lost its mysql connection (its no timeout 
since the function doesnt take long to execute).

the same scripts work with PHP version 4.0.1pl2. both pcs have the same setup (apache 
1.3.12, mysql 3.22.32, the rest as rpms from the distibution cds). its all the same 
except the php-version (both compiled with the standard options --with-apxs 
--with-mysql -> make -> make install)


-- 
Edit Bug report at: http://bugs.php.net/?id=9497&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to