Re: A simple IF condition.
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: A simple IF condition.

From: Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputer.com>
Date: Fri Sep 02 2005 - 14:49:26 CEST

*** Alec wrote/escribió (2 Sep 2005 05:46:29 -0700):
> $check = @mysql_query ("SELECT townname FROM site01_towns WHERE
> townname='$townsearch'");
> if (!$check)
> {
> echo '<p>Cannot Find The Town</p>';
> exit();
>
> }

Let's check mysql_query() manual page:

"Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query() returns
a resource identifier or FALSE if the query was not executed correctly.
[...] A non-FALSE return value means that the query was legal and could be
executed by the server. It does not indicate anything about the number of
rows affected or returned. It is perfectly possible for a query to succeed
but affect no rows or return no rows."

Your if condition will only be FALSE if you have a syntax error in your SQL
query.

-- 
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Received on Tue Oct 18 02:17:41 2005