User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,081 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,968 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3838 | Replies: 3
Reply
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

test mysql query for no results

  #1  
Jan 28th, 2007
Hey, I'm running a mysql query, and would like to run a script if the query returns no results. But what do I use to test for no results?

Something like:

[PHP]

if (!$query) {

do this

}

[/PHP]

But just not sure how to implement it. Little help?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: test mysql query for no results

  #2  
Jan 28th, 2007
  1. if(mysql_num_rows($result)==0){
  2. //do this
  3. }
Last edited by php_daemon : Jan 28th, 2007 at 5:21 pm.
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: test mysql query for no results

  #3  
Jan 30th, 2007
Originally Posted by php_daemon View Post
  1. if(mysql_num_rows($result)==0){
  2. //do this
  3. }

Thanks, that was perfect.
Reply With Quote  
Join Date: Mar 2008
Posts: 3
Reputation: 1supergirl is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
1supergirl 1supergirl is offline Offline
Newbie Poster

Re: test mysql query for no results

  #4  
Mar 16th, 2008
Originally Posted by php_daemon View Post
  1. if(mysql_num_rows($result)==0){
  2. //do this
  3. }

OMG, you helped me so much!! I am new to php, and I was tearing my hair out. Thank you, Thankyou,! You are my hero!!!!!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 12:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC