Re: MySQL frustration
| From: | Tom Peck | Date: | Tue, 18 Jul 2000 02:56:36 +0000 |
| Subject: | Re: MySQL frustration | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7008@lists.php.net to get a copy of this message | ||
That's superb Billy.. thanks for the quick help - I knew it must have been
something simple - I think I'll grab a coffee - my brains not functioning
too well today.
Cheers
Tom
----- Original Message -----
From: Billy Harvey <Billy.Harvey@RhinoComputing.com>
To: Tom Peck <tompeck@paradise.net.nz>
Sent: Tuesday, July 18, 2000 2:53 PM
Subject: Re: MySQL frustration
> Tom Peck writes:
> > 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?
> >
> > Thanks for any help.
> >
> >
> > // The frustrating code
> >
> > $tempName = "This Person";
> >
> > $sql = "SELECT * FROM tblPlayers WHERE fldName='$tempName'";
> > $result = mysql_query($sql);
> >
> > if ( $result ) {
> > echo "<br> RESULT TRUE!";
> > }
> >
> > else
> >
> > echo "<br> RESULT FALSE!";
> > }
>
> Tom,
>
> $result is still a mysql array.
>
> Try testing like so:
>
> if (mysql_num_rows($result) == 0) {
>
> echo "Not found";
>
> } else {
>
> echo "Found";
> }
>
> Billy
>