On Mon, 27 May 2002 [EMAIL PROTECTED] 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'] . '"';


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

Reply via email to