Welcome to WebmasterWorld Guest from 54.145.173.36

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Notice: Undefined index

   
7:56 am on Nov 3, 2006 (gmt 0)

5+ Year Member



I got this error message below. How can i fix it...

PHP Notice: Undefined index: REQUEST_URI in c:\inetpub\wwwroot\guestbook\guestbook.php on line 41 PHP Warning: Cannot add header information - headers already sent in c:\inetpub\wwwroot\guestbook\guestbook.php on line 41

any help is very much appreciated.

8:38 am on Nov 3, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld Othenz,

what is on line 41?

is this stopping your script? I notice the headers already sent error there too.

11:28 am on Nov 3, 2006 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Welcome!

My guess is that you just don't have quotation marks around the array index like so:


$_SERVER[[b]"[/b]REQUEST_URI[b]"[/b]]

Also, to get rid of the header warning you must place any calls to header [us2.php.net] before any text is output to the browser. Read it's documentation for some other fixes regarding using output buffers.

Good luck!

[edit]
Ok I take back my guess, because it throws a different error (I should have known, too)

So yes, what's that line of code :)
[/edit]

11:19 pm on Nov 3, 2006 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The header error is appearing because of the text generated by the undefined error. Check out eelixduppy's excellent advice, which I`m sure is the problem.

dc

7:51 am on Nov 3, 2006 (gmt 0)

5+ Year Member




System: The following 2 messages were spliced on to this thread from: http://www.webmasterworld.com/php/3146246.htm [webmasterworld.com] by coopster - 4:54 pm on Nov. 6, 2006 (utc -6)


I got this error message below in my php guestbook. I'm using IIS as my webserver.

[1]PHP Notice: Undefined index: REQUEST_URI in c:\inetpub\wwwroot\guestbook\guestbook.php on line 41 PHP Warning: Cannot add header information - headers already sent in c:\inetpub\wwwroot\guestbook\guestbook.php on line 41 [1]

I don't know what went wrong...

Any help is very much appreciated...

10:49 pm on Nov 6, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, Othenz.

The headers already sent error is being thrown because of the NOTICE error being dumped to the browser first. You cannot have any output whatsoever prior to the header [php.net] function, including errors.

But, that error is secondary. First, you need to find out why you don't have a REQUEST_URI index in your $_SERVER superglobal. I'm guessing it is because you are running IIS and there is no index of REQUEST_URI (you will indeed find that index in on an Apache HTTP server though). You may have to find out the equivalent on IIS.