In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to