RE: [PHP] Parse Error(Newbie)

From: Date: Mon, 27 May 2002 13:17:06 +0000
Subject: RE: [PHP] Parse Error(Newbie)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99365@lists.php.net to get a copy of this message
Also note that variables are case sensitive in PHP. So $_get and $_GET are not the same. If you're using the new "super-global" variables on PHP, then you need to use $_GET['id']... ---John Holmes... > -----Original Message----- > From: Miguel Cruz [mailto:mnc@stoic.net] > Sent: Monday, May 27, 2002 2:18 AM > To: webmaster@tececo.com > Cc: php-general@lists.php.net > Subject: Re: [PHP] Parse Error(Newbie) > > On Mon, 27 May 2002 webmaster@tececo.com wrote: > > I know it is probably something obvious but the following gives me a > > parse error and as a newbie I am having trouble locating it. > > > > $query = "select * from news WHERE id = "$_get['id']""; > > A lot of people have answered this already, but just for a little more > clarification, consider this: > > The reason the computer requires you to surround a string with quotes is > so that it knows where the string begins and ends. > > If you put quotes in the middle of the string, it thinks those mark the > end; why would it think otherwise, since that's what quotes are for. > > So people have provided you with various solutions for this. Each of them > involve in some way indicating more specifically what's going on. Either > you use a different kind of quotes (if you started the string with single > quotes, it will let you put double quotes inside it without getting > confused, and vice versa), or you use the backslash character before > internal quotes. Backslash is the "escape" character which in this case > tells the parser to ignore the special meaning of the quote that follows. > So your line could have been written in any of the following ways: > > $query = "select * from news WHERE id = '{$_get['id']}'"; > $query = "select * from news WHERE id = \"{$_get['id']}\""; > $query = 'select * from news WHERE id = "' . $_get['id'] . > '"'; > > miguel > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#99365) next »