Reserved Words; possibly deprecated?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Twayne
Forum Newbie
Posts: 14
Joined: Fri Jun 20, 2008 11:47 am

Reserved Words; possibly deprecated?

Post by Twayne »

Hi,
This is pretty simple, I think, and more to settle an annoyance than a real "problem" but also to be sure I'm not doing something stupid.
Rank newbie, XP Pro/SP2, Apache local and remote both, PHP 5.2.5 local and remote.

-- Is/Has "num" a/ever been reserved word? If it is/was, then I'm fine. If it's not/was never, then I'm confused by the error message that' bugged me for a couple of hours before I finally wised up!!

In:

Code: Select all

 
<?php 
...
   $_SESSION['num']=$no;
... ?> 
 
"num" above causes this error message:
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


Setting "num" to anything else ('no', 'numb', 'nom', etc.) does not cause the error message to be displayed.
Both ... _42 and ..._warn are set to on (1) and I see I can just turn off the message, but that smacks of a bandaid solution. I'd rather know more WHAT the message actually means in this case. The only thing I can figure it is must have been a reserved word or something at one time. True? False?

More incclusive code, just for GPs; not really necessary I don't think:

Code: Select all

 
<?php
 // nuentry.php
    session_start();
    $quantity = 3;      // old quantity of items to buy
    if (isset($_SESSION['count'])) {        // sessions counting
      $count = $_SESSION['count'];
   } else {
      $count = 0;
   }
   $count++;
   $_SESSION['count'] = $count;
   $_SESSION['n0']=$no;
   echo "Page Displays is: " . $count . "<br>";
?>
...
Form code here
...
 
Thanks for your time,

Twayne
Last edited by Weirdan on Sat Jun 21, 2008 11:00 am, edited 1 time in total.
Reason: bbtags
smcalpine
Forum Newbie
Posts: 2
Joined: Sat Jun 21, 2008 6:54 am

Re: Reserved Words; possibly deprecated?

Post by smcalpine »

Avoid using the same names for session variables and normal variables, use the session variables all the time:

Code: Select all

<?php
// nuentry.php
 
    session_start();
 
    if (!isset($_SESSION['count'])) {        // sessions counting
      $_SESSION['count'] = 0;
   }
 
   $_SESSION['count']++;
 
   echo "Page Displays is: " . $_SESSION['count'] . "<br>";
 
?>
You're getting the error because in older versions of PHP changes to $count would also be applied to $_SESSION['count'].
Post Reply