php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3004 Returning function value is lost whe set to a session variable
Submitted: 1999-12-19 09:45 UTC Modified: 1999-12-23 07:55 UTC
From: gbonanse at tesetec dot com dot br Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (19/12/1999) OS: Linux2.2.13/Apache1.3.9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gbonanse at tesetec dot com dot br
New email:
PHP Version: OS:

 

 [1999-12-19 09:45 UTC] gbonanse at tesetec dot com dot br
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-12-22 22:19 UTC] sas at cvs dot php dot net
reclassifying as a Scripting Engine problem

Please check whether it happens with the latest CVS. There have been numerous changes in Zend during the last days.
 [1999-12-23 07:55 UTC] gbonanse at tesetec dot com dot br
Fixed on the last CVS.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 19:01:36 2025 UTC