ID:               41540
 User updated by:  essem76 at yahoo dot com
 Reported By:      essem76 at yahoo dot com
 Status:           Bogus
 Bug Type:         Session related
 Operating System: Windows Server 2000
 PHP Version:      5.2.2
 New Comment:

The thing is that a null value assignment to a session variable is
perfectly acceptable. But an already uninitialized php variable can not
be assigned to a session variable!! I can't understand why? But..
Also the warning message is also confusing as I am already using
version 5.2.0


Previous Comments:
------------------------------------------------------------------------

[2007-05-30 12:06:03] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.



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

[2007-05-30 11:53:06] essem76 at yahoo dot com

Description:
------------
If that iritating warning occurs then check the mistyped PHP variables
assigned to session variable.
I faced the same problem and half an hour after getting on my nerves I
found the typing mistake and the nasty warning disappeared.
As there aren't many articles when I googled, I thought this might be
help someone..

Reproduce code:
---------------
<?php
session_start();
function checkArrEmpty($arr){
        $flag = false;
        if(is_array($arr)) {
                foreach($arr as $val){
                        if($val == ""){
                                $flag = true; break;
                        }
                }
        }
        return $flag;
}
if(!$_SESSION['blnFormDataValid']){
        $arrUserData = $_SESSION['arrFormData'];
}

if(isset($_POST['btnAdd'])){
        $arrFormData = $_POST;
        if(!checkArrEmpty($arrFormData)){
                $_SESSION['blnFormDataValid'] = true;
                $_SESSION['arrFormData'] = "";  //header("location:
XTemp.php");    //exit();
        }
        else{//THE following nasty variable mistyped (look for small case d in
data) is creating a hell.
                //Simply replace $arrFormdata to $arrFormData and see the
difference.
                $_SESSION['arrFormData'] = $arrFormdata;
                $_SESSION['blnFormDataValid'] = false;
        }
}
?>
<form id="frmUser" method="post" action="<?php echo
$_SERVER['PHP_SELF']; ?>">
        <label>First Name: </label><input type="text" name="fName"
value="<?php echo $arrUserData['fName']; ?>" /><br/>
        <label>Last Name: </label><input type="text" name="lName" value="<?php
echo $arrUserData['lName']; ?>" /><br/>
        <input type="submit" name="btnAdd" value="add" />
</form>

Expected result:
----------------
The code is expected to check the server side validations of the form
inputs failing which will generate the same form but with the partially
filled values this time.

Actual result:
--------------
The following warning is displayed even in PHP 5.2.0:-

Warning: Unknown: Your script possibly relies on a session side-effect
which existed until PHP 4.2.3. Please be advised that the session
extension does not consider global variables as a source of data, unless
register_globals is enabled. You can disable this functionality and this
warning by setting session.bug_compat_42 or session.bug_compat_warn to
off, respectively. in Unknown on line 0


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


-- 
Edit this bug report at http://bugs.php.net/?id=41540&edit=1

Reply via email to