PDA

View Full Version : PHP error in 1.5rc4 - PHP Notice: Undefined index: HTTP_ACCEPT_ENCODING


Oceanwatcher
15th of August 2005 (Mon), 20:07
On my new site, www.oceanwatcher.com, I have an error in the log that I would like to fix. I tried searching for it and could not find any solutions.

PHP Notice: Undefined index: HTTP_ACCEPT_ENCODING in /xxx/xxx/xxxx/list.php on line 5494

Anyone that can help? It would be nice to clear the log of stuff like this.... :-)

triadib
16th of August 2005 (Tue), 03:12
Hi,

my list.php (in /GALLERY) has only 2944 lines???
Perhaps there are hidden characters in the end of your script caused by copy/paste...

Try, opening the script in vi, move to the end and delete all lines after "?>" or reinstall the script from the source.

Best regards from Germany
Dirk

Oceanwatcher
16th of August 2005 (Tue), 06:18
my list.php (in /GALLERY) has only 2944 lines???
Perhaps there are hidden characters in the end of your script caused by copy/paste...
Dirk

No copy/paste that I know of. BUT - I will try most things :-) Reinstall is not an option. Have done a few modifications, and this is just an annoyance, not something that causes royal pain...

Just checked my list.php and it has 5888 lines. Go figure. Everything works perfectly... Anyone that can shed some light on this? And there is only one occasion of eof...

Pekka, can you shed some light on this?

triadib
16th of August 2005 (Tue), 09:31
OK - PHP is counting the lines in another way than vi or any editor do.

You've got 5888 lines - 2944 x 2 = 5888, so the error is located in line 2747.

I take a look in the script and the paragraph has something to to with the performance data, but futher more I think only Pekka can help.

Dirk

Pekka
16th of August 2005 (Tue), 12:30
Those environment variables are not always available on server, and are in this case used only for status logging. You can silent them by changing

$HTTP_SERVER_VARS['SERVER_NAME'];

to

@$HTTP_SERVER_VARS['SERVER_NAME'];


$HTTP_SERVER_VARS['SERVER_PROTOCOL'];

to

@$HTTP_SERVER_VARS['SERVER_PROTOCOL'];

and

$HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'];

to

@$HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'];

Oceanwatcher
16th of August 2005 (Tue), 16:20
I am getting some more errors from the feedback.php file. Could this be related?

[Tue Aug 16 19:53:31 2005] [error] PHP Notice: Undefined variable: valid in /xxxx/xxxxx/xxxxxx/feedback.php on line 807
[Tue Aug 16 19:53:31 2005] [error] PHP Notice: Undefined variable: select_output in /xxxx/xxxxx/xxxxxx/feedback.php on line 750
[Tue Aug 16 19:53:31 2005] [error] PHP Notice: Undefined variable: search_row in /xxxx/xxxxx/xxxxxx/feedback.php on line 748
[Tue Aug 16 19:53:31 2005] [error] PHP Notice: Undefined variable: select_output in /xxxx/xxxxx/xxxxxx/feedback.php on line 671
[Tue Aug 16 19:53:31 2005] [error] PHP Notice: Undefined variable: search_row in /xxxx/xxxxx/xxxxxx/feedback.php on line 669

HMetal
17th of August 2005 (Wed), 14:36
I know this is nitpicky and probably I'm being pedantic due to spending the last 6 years developing PHP applications and being an OP in the #php channel on efnet, but I am curious..

1. Why aren't you using the newer/better superglobal variables instead of using those old-style global variable names? I'm sure most sensible, security conscious hosts have upgraded past PHP 4.1.2 where the newly implemented superglobals were found to be stable. You should change those to superglobals and require PHP 4.1.2 or greater for EE.

2. Even if those variables were not defined in his installation, he shouldn't be getting warnings if the code followed certain variable access standards. I know he can disable PHP error/warning messages but the better way would be to use a conditional test on variables before you access their values.

e.g.

if(!empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { /* code accessing server variable HTTP_ACCEPT_ENCODING goes here */ }

OR

if(isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { /* code accessing server variable HTTP_ACCEPT_ENCODING goes here */ }

Either will work and this would make life simpler for those of us that keep PHP error reporting set at E_ALL and then EE won't fill up our logs with warnings when generated. http://www.photography-on-the.net/forum/images/smilies/icon_smile.gif


Those environment variables are not always available on server, and are in this case used only for status logging. You can silent them by changing

$HTTP_SERVER_VARS['SERVER_NAME'];

to

@$HTTP_SERVER_VARS['SERVER_NAME'];


$HTTP_SERVER_VARS['SERVER_PROTOCOL'];

to

@$HTTP_SERVER_VARS['SERVER_PROTOCOL'];

and

$HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'];

to

@$HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'];

Oceanwatcher
17th of August 2005 (Wed), 21:10
Well, no more errormessages from list.php the last day. Thank you, Pekka.

Now I only have to worry about the feedback.php messages. Can those errors mess up the feedback system?