Just wondering if you could check if something wasnt found..

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rsbeaulieu
Forum Newbie
Posts: 6
Joined: Tue Jul 02, 2002 6:02 am
Location: NH

Just wondering if you could check if something wasnt found..

Post by rsbeaulieu »

ive been using a statement exactly like

Code: Select all

if( ! $qry ) { 
echo("<p>Error:".mysql_error()."</p>"); 
&#125;
the if(! $qry) is something that is used to determine if an error was found but i would like to check if you found nothing, nothing at all, zip, notta thing. So is that possible? 8O
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

if(empty($qry)){
}

but uhm...

!$qry should return true if nothing is found..
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Do something like:

Code: Select all

$result = mysql_query("Your query here");
if( mysql_num_rows($result) == 0 )
  echo "No results found.";
else
&#123;
  // Do stuff with the results
&#125;
rsbeaulieu
Forum Newbie
Posts: 6
Joined: Tue Jul 02, 2002 6:02 am
Location: NH

Post by rsbeaulieu »

seems to be working now. Thanks. 8O
rsbeaulieu
Forum Newbie
Posts: 6
Joined: Tue Jul 02, 2002 6:02 am
Location: NH

Post by rsbeaulieu »

Hey it works like a charm now, thanks again! :D
Post Reply