Re: Question about $_GET

From: Date: Wed, 15 Jan 2003 15:18:49 +0000
Subject: Re: Question about $_GET
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-131710@lists.php.net to get a copy of this message
--- Frank Keessen <fkeessen@planet.nl> wrote: > So the code looks like this: > > $query = "SELECT Newsheadline, News, Contact FROM news > WHERE Newsid = $_GET['id']"; > > But all i'm getting in my browser is: > > parse error, expecting T_STRING' or T_VARIABLE' or > `T_NUM_STRING' I could not tell if your question had been adequately answered, but there is an easy way to deal with these types of things without worrying yourself with syntax. Just use concatenation (.) as follows: $query = "select newsheadline, news, contact from news where newsid = '" . $_GET['id'] . "'"; This builds $query using three separate strings. The first and third strings are double quoted, and the middle string is your variable. Note another difference is that the value of $_GET['id'] is going to be surrounded by single quotes once $query is constructed. Chris

« previous php.general (#131710) next »