Re: MySQL frustration
| From: | Bill Stilwell | Date: | Tue, 18 Jul 2000 03:00:55 +0000 |
| Subject: | Re: MySQL frustration | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7011@lists.php.net to get a copy of this message | ||
On Tue, Jul 18, 2000 at 02:43:08PM +1200, Tom Peck wrote:
> Good afternoon everyone
>
> I'm tearing my hair out over this one - it seems so simple - but it's not
> doing what it's told... All I want to do is check if $tempName exists in
> the database - and if it doesn't I want to know. BUT no matter what i have
> tried - it either doesn't think it exists when it does - or the opposite.
> This is the latest piece of code I have been trying - can anyone find any
> problems with it? It seems that $result is always true - no matter what
> $tempName is equal to. How is this possible?
It's because $result *is* always true! $result is a "handle" for the
results from your mysql query - if you want to check to see if any
rows were returned, use if (mysql_num_rows($result)). $result will
only be zero if the mysql query fails, not just if it returns zero
results.
--
Bill Stilwell
bill@marginalia.org
It's all margins.
Oh, just read my weblog: http://www.marginalia.org