PHP 4.0 Bug #3004: Returning function value is lost whe set to a session variable
| From: | gbonanse at tesetec dot com dot br | Date: | Sun, 19 Dec 1999 14:45:16 +0000 |
| Subject: | PHP 4.0 Bug #3004: Returning function value is lost whe set to a session variable | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-13843@lists.php.net to get a copy of this message | ||
From: gbonanse@tesetec.com.br
Operating system: Linux2.2.13/Apache1.3.9
PHP version: 4.0 Latest CVS (19/12/1999)
PHP Bug Type: Misbehaving function
Bug description: Returning function value is lost whe set to a session variable
I have the folowing function:
function renewloc ($lset,&$l,&$ld) {
$db = mysql_connect();
mysql_select_db("cefac",$db);
$sqls = "SELECT locid,locnome FROM locais ORDER BY locid";
$result = mysql_query($sqls,$db);
$row = mysql_fetch_row($result);
if ($lset)
{
$l = $row[0];
$ld = $row[1];
}
$larr = '';
do {
$larr = $larr . $row[0] . "|" . $row[1] . "@";
} while ($row = mysql_fetch_row($result));
mysql_close($db);
return substr($larr,0,strlen($larr)-1);
}
The function works well, set the referenced variables and returns a result. Within the page from
which the function was called I can play with the result, but if I set a session variable with this
result, the session file is written with this value as an integer with value 0;
If I use the following code:
include('funct.inc');
$myvar = renewloc(true,$mg_loc,$mg_locd);
where 'funct.inc' is the include page where I have the renewloc function defined, $tmp has
the right value as soon as the function returns, but now look at this code:
session_register('myvar');
session_register('mytest');
include('funct.inc');
$myvar = renewloc(true,$mg_loc,$mg_locd);
$mytest = 'testing';
myvar has the right value, but on the next page, only the mytest value is held. myvar is written as
an integer value that contains 0.
If I substitue the function by its code directly on the page everything works fine. Maybe this is a
problem inserted on the last changes of referencing variables.