Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP error

Status
Not open for further replies.

axman505

Technical User
Jun 20, 2001
489
US
I installed php 4.3.dev the other day and now i get this error:

Warning: 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

i tried setting session.bug_compact_warn to 0, but it still had no effect.

i am runing php 4.3.dev with apache 2.0.43

any suggestions would be greatly appreciated. thanks!
 
i was more asking how to disaply the error, not rewrite the script
 
Unrecognized word in your last post. Am assuming the word "disaply" should be "disable".


That sounds like an awfully serious error to be disabling it. If the code does use the bug the warning mentions, then you're going to get strange behavior from the script. ______________________________________________________________________
TANSTAAFL!
 
sorry about the type, it was suppose to be disable, the turkey was clouding my typing. I will have to contact the writers of the script so they can look at the issue, but for the mean time i want to disable the warning, but i cannot get it to go away.
 
i wouldnt necessarily call this code experimental. it is a well known photo gallery script.
 
It sounds to me like Gallery is doing something with session variables that PHP 4.3.0 doesn't like.

Assuming that you're running PHP as an Apache module, and that you restarted Apache after making the change to php.ini that the message suggested, then report the problem as a bug. ______________________________________________________________________
TANSTAAFL!
 
Hi, I encountered the very same problem, but with a simpler script.

the codes are as follows:

<?php

// count_me.php
// if session does not yet exist for this user, start one

session_start();
session_register('count');
$count++;
echo &quot;<P> you been here $count times. cheers</P>&quot;;


?>
 
i get the very same error message

&quot;Warning: 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&quot;
 
I recommend that you rewrite your script as:

<?php

// count_me.php
// if session does not yet exist for this user, start one

session_start();
if (! array_key_exists('count', $_SESSION))
{
$_SESSION('count') = 1;
}
else
{
$_SESSION('count')++;
}

echo &quot;<P> you been here $count times. cheers</P>&quot;;


?>


Your error is caused by the fact that your PHP runtime configuration directive &quot;register_globals&quot; is set to &quot;off&quot;. I recommend that you keep it that way for two reasons: first, because the online manual recommends it at ; second, because it improves code maintainability.

If you reference $_SESSION directly, do not use session_register(), IAW a caution block at Want the best answers? Ask the best questions: TANSTAAFL!
 
Oops.

the problem got worse.

after i tried using your codes, i get this error


Parse error: parse error, unexpected '=' in C:\Program Files\Apache Group\Apache2\htdocs\tutorials\session_count_working.php on line 9
 
another question

if i want to set the &quot;register_globals&quot; to ON, where should i change the runtime configuration directive?

the php.ini file or some other files within apache?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top