Re: error and general problems

From: Date: Mon, 26 Mar 2001 17:39:31 +0000
Subject: Re: error and general problems
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7836@lists.php.net to get a copy of this message
In article <4.3.2.7.2.20010326112519.00b57a50@dogwood.cisco.com>, lbander@cisco.com (Liz Bander) wrote: > I am getting a parse error for the return line every time I try and view > the page. Can anyone tell me why? The code is below. > > $results = "select req, source, number from orders where req=" . > $GLOBALS["req"] . ", source=" . $GLOBALS["source"] . ", > number=" .$GLOBALS["req"] . ""; > > if (mysql_fetch_row($results) != 0) { > return "This has already been added."; Is this inside a function? 'Cuz AFAIK a "return" would only make sense inside a function. FWIW, the comparison of the fetched row to zero strikes me as a bit unusual. Are you just checking whether there was no rows were returned by the query? If so, I suspect that checking mysql_num_rows() would be more efficient. > Also (since this is part of the problem, I'm sure) how do I take the > $GLOBALS values and set them equal to the req and source values in the > select statement? Is this syntax correct? Depends. MySQL needs string values quoted too, so if for example all of those variables are strings you'd do something like: $results = "select req, source, number from orders where req='" . $GLOBALS["req"] . "', source='" . $GLOBALS["source"] . ", number='" . $GLOBALS["req"] . "'"; -- CC

« previous php.db (#7836) next »