Re: mysql if empty
| From: | afan at afan dot net | Date: | Mon, 09 Apr 2007 21:25:06 +0000 |
| Subject: | Re: mysql if empty | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252368@lists.php.net to get a copy of this message | ||
> If I search for something in mysql that returns an empty result I cant get
> it to return
> "No result found" always returns "Found" even though the recoed does not
> exist...
>
>
> $sql = "SELECT Client FROM booked WHERE Name = 'larry'";
>
> $result = mysql_query($sql);
>
> if ($result == "")
> {
> echo "No result found";
> }
> echo "Found";
try this:
$sql = "SELECT Client FROM booked WHERE Name = 'larry'";
$result = mysql_query($sql);
if(mysql_num_rows($result) == 0)
{
echo "No result found";
}
else
{
$myresults = mysql_fetch_array($result);
}
-afan
>
>
> ----- Original Message -----
> From: "Martin Marques" <martin@bugs.unl.edu.ar>
> To: "Stut" <stuttle@gmail.com>
> Cc: "Tijnema !" <tijnema@gmail.com>; "tedd"
> <tedd@sperling.com>; "Peter
> Lauri" <lists@dwsasia.com>; "Ólafur Waage" <sinai@simnet.is>;
> <php-general@lists.php.net>
> Sent: Monday, April 09, 2007 9:45 PM
> Subject: Re: [PHP] Session Authentication
>
>
>> Stut escribió:
>>> As with most things these days it probably breaches the DMCA. But
>>> frankly
>>> speaking, if doing that works then the developers of the application,
>>> and
>>> by extension the company, deserve everything they get.
>>
>> DMCA is a real piece of crap.
>>
>> --
>> select 'mmarques' || '@' || 'unl.edu.ar' AS email;
>> ---------------------------------------------------------
>> Martín Marqués | Programador, DBA
>> Centro de Telemática | Administrador
>> Universidad Nacional
>> del Litoral
>> ---------------------------------------------------------
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>