[PHP] "Use of undefined constant" error

2002-12-17 Thread fragmonster
Hello,
I've got a strange pb. Here's my code


if(isset($_GET[id])){
	do something...
else
	do something else
}
?>

When I call myfile.php I've got the "somthing else" with no error.
When I call myfile.php?id=1 I've got the "something" but with an error 
message "Notice: Use of undefined constant id - assumed 'id' in ..."

Please help


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] "Use of undefined constant" error

2002-12-17 Thread fragmonster
Hello,
I've got a strange pb. Here's my code


if(isset($_GET[id])){
do something...
else
do something else
}
?>

When I call myfile.php or myfile.php?id=1 I've got an error message 
"Notice: Use of undefined constant id - assumed 'id' in ..."

Please help


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] "Use of undefined constant" error

2002-12-17 Thread Jon Haworth
Hi,

> "Notice: Use of undefined constant id - assumed 'id' in ..."

Try changing this:

> if(isset($_GET[id])){

to this:
  if(isset($_GET['id'])) { 
 
  note quotes

PHP thinks you're trying to use a constant called "id", which you haven't
defined - hence the "undefined constant" error ;-)

Note how the message says "assumed 'id'", which is what you should change it
to - this shouldn't stop your script from running, as the parser can work
out what you meant, but your error reporting is set sufficiently high that
PHP lets you know about it.

Cheers
Jon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] "Use of undefined constant" error

2002-12-17 Thread Tim Ward
you've got error reporting set pretty high to get that.
The correct way to reference an array element in this case
is $_GET["id"], if you do $_GET[id] you are telling PHP
to look for a constant called id. If it doesn't find one then
it assumes you meant "id" onstead of id and proceeds 
accordingly. Thats why you can get away with not using the 
quote marks (as long as there's no white space in the string).

On a live site (and, I'd have thought, most default set-ups) 
you'd expect error reporting to be set all off and you'd 
never see the message.

Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
- Original Message - 
From: fragmonster <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 10:49 AM
Subject: [PHP] "Use of undefined constant" error


> Hello,
> I've got a strange pb. Here's my code
> 
>  if(isset($_GET[id])){
>  do something...
> else
>  do something else
> }
> ?>
> 
> When I call myfile.php or myfile.php?id=1 I've got an error message 
> "Notice: Use of undefined constant id - assumed 'id' in ..."
> 
> Please help
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php