Forum Moderators: coopster

Message Too Old, No Replies

Undefined offset: 1 in (site root)/scripts/checkuserlogphp on line77

         

bedirect

12:47 am on Sep 27, 2011 (gmt 0)

10+ Year Member



So im having this issue. It only seems to effect varying IE browsers, for instence My IE on my pc shows the website no problem. so does the IE on my little netbock has no trouble either. However the IE on my laptop and on my mothers pc shows this error and wont show the site.

Notice: Undefined offset: 1 in (site root) /scripts/checkuserlog.php on line 77

Warning: Cannot modify header information - headers already sent by (output started at (site root)/scripts/checkuserlog.php:77) in
(site root)/scripts/checkuserlog.php on line 84

Warning: Cannot modify header information - headers already sent by (output started at (site root)/scripts/checkuserlog.php:77) in
(site root)/scripts/checkuserlog.php on line 85

Warning: Cannot modify header information - headers already sent by (output started at (site root)/scripts/checkuserlog.php:77) in
(site root)/scripts/checkuserlog.php on line 86

I cant figure this out if there is anymore info you may need i can add more.

omoutop

6:03 am on Sep 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



welcome to webmasterworld

the message "Warning: Cannot modify header information - headers already sent" indicates that you (or your script) outputs some form of data (an echo command, or a space character or something else), before the usage of headers.

Check and make sure that nothing is printed before you echo your header().

Status_203

8:06 am on Sep 27, 2011 (gmt 0)

10+ Year Member



By the looks of it there is something (cookies?) in your(?) code that involves sending HTTP Headers. All HTTP headers need to be sent before any of the page content has been sent (even a space).

However, it looks like you also have a bug that is outputting the "Notice:" i.e. page content (even if it is unwanted content). Fix that, so that you don't get the warning, and you may find that the header issue disappears.

<edit>Take a look at what variables are used on line 77 and use print_r just before that line to output what they contain. That might give you a starting point.</edit>

[edited by: Status_203 at 8:09 am (utc) on Sep 27, 2011]

penders

8:07 am on Sep 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The warnings... "Warning: Cannot modify header information - headers already sent" are simply because of the first message that is output, "Notice: Undefined offset: 1 in ...". Fix the 'Notice' and you fix the 'Warnings'.

Notice: Undefined offset: 1 in (site root) /scripts/checkuserlog.php on line 77


This is because you are trying to access the array element with index 1, but it has not yet been set - it is undefined. Note that is not a "Warning" or an "Error", it is just a "Notice", but highlights a potential problem with the code. PHP will default this value, so your script probably works OK.

The following code will produce the same 'notice':
$myArray = array (); 
$myArray[] = 'Hello'; // Index/Offset 0
echo $myArray[1]; // Notice: Undefined offset: 1


You can suppress "Notice" messages from being output in the first place by lowering the error_reporting() level:
error_reporting(E_ALL & ~E_NOTICE);


But this is generally a bad idea whilst developing.

It is possible that this is how the code was originally written (or is this your code?), to take into account PHP's default behaviour, but this is usually best avoided....
$myArray = array(); 
$myArray[] = 'Hello';
if (isset($myArray[1])) {
echo $myArray[1];
} else {
echo 'Not Set Yet!';// This gets output
}


Why should this only affect certain browsers?! The user logging script would seem to be checking certain browser characteristics so there could certainly be differences, but apart from that it's hard to say.

bedirect

2:40 pm on Sep 28, 2011 (gmt 0)

10+ Year Member



dont know how to close this thread out

penders

3:28 pm on Sep 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you managed to resolve the problem? Were any of the comments helpful?