From:             jan dot morten dot sorensen at organizer dot net
Operating system: Win2K
PHP version:      5.2.1
PHP Bug Type:     Unknown/Other Function
Bug description:  session_start() kills link resource variable

Description:
------------
I have version 5.1.2. THIS MIGHT HAVE BEEN FIXED IN 5.2.1!!!

First use mysql_connect() on an included file and return the resource
identifier and store this in a variable.
Then call session_start()
Now you have lost your resource identifier!
Calling session_start() first fixes the problem.

Reproduce code:
---------------
file1.php
function connect_to_db() {
  $link = mysql_connect($host, $user, $pass) or die(err_msg);
  mysql_select_db($db) or die(err_msg);
  return $link;
}
file2.php
include 'file1.php';
$link = connect_to_db();
echo $link;
session_start();
echo $link;

Expected result:
----------------
link resource id# ?
link resource id# ?

replace ? with a number

Actual result:
--------------
link resource id# ?
0

-- 
Edit bug report at http://bugs.php.net/?id=40615&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40615&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40615&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40615&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40615&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40615&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40615&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40615&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40615&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40615&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40615&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40615&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40615&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40615&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40615&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40615&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40615&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40615&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40615&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40615&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40615&r=mysqlcfg

Reply via email to