Re: [PHP] mysql if empty



$result == "" means:
Your SQL query is so f'ed up, I couldn't even run it.

It does NOT mean:
Your query returned zero rows, a perfectly normal and common condition.

You want http://php.net/mysql_num_rows

And, actually, $result is FALSE, not really "", when the query is wrong.

On Mon, April 9, 2007 4:18 pm, chris@xxxxxxxxxxxx wrote:
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";


----- Original Message -----
From: "Martin Marques" <martin@xxxxxxxxxxxxxxx>
To: "Stut" <stuttle@xxxxxxxxx>
Cc: "Tijnema !" <tijnema@xxxxxxxxx>; "tedd" <tedd@xxxxxxxxxxxx>;
"Peter
Lauri" <lists@xxxxxxxxxxx>; "Ólafur Waage" <sinai@xxxxxxxxx>;
<php-general@xxxxxxxxxxxxx>
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




--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • Re: [PHP] Re: can a session be used in a query?
    ... echo 'No records found.'; ... anyone have ideas for me, the session user is working, and I need to ... the query UserName = $UserName I get an undefined variable error... ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] Re: can a session be used in a query?
    ... echo 'No records found.'; ... anyone have ideas for me, the session user is working, and I need to ... the query UserName = $UserName I get an undefined variable error... ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] Re: can a session be used in a query?
    ... anyone have ideas for me, the session user is working, and I need to ... the query UserName = $UserName I get an undefined variable error... ... PHP General Mailing List ... further along, the query is working, I can echo fields ...
    (php.general)
  • Re: [PHP] array issues
    ... I think you ment ... are doing, but with only the query to look at, it's hard to tell... ... I have paste a sample record below; ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] db query not working
    ... I saw two people pointing two errors on the SQL insert statement which you would have found yourself had you put the 'or die' at the end of the query, ... $result = mysql_query ("SELECT DISTINCT company FROM view_log WHERE company!= ''"); ... It dumps the table fine, works the explode, outputs the string in the echo command the way I expect, but doesn't place the value in tmphitsmag table. ... PHP General Mailing List ...
    (php.general)