Urgent help needed (How to echo message if MySQL returns emp

  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post October 25th, 2009, 5:27 am

Urgent help needed (How to echo message if MySQL returns empty set).

Any syntax for this?
I have tried many couldn't work, if it's empty set it displays blank page, but what I'm trying to accomplish is echoing some message instead.

e.g I have tried

Code: [ Select ]
if ($fname == "" || $day == "" || $time == "") {
echo "Employee is assigned on another department!, please Search Employee for details..";

if (!$result) {...

or if


$num=0?
  1. if ($fname == "" || $day == "" || $time == "") {
  2. echo "Employee is assigned on another department!, please Search Employee for details..";
  3. if (!$result) {...
  4. or if
  5. $num=0?


I still have about 8 hours to solve this. Please help, guys.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 25th, 2009, 5:27 am

  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Joined: Feb 27, 2006
  • Posts: 48
  • Loc: Reno, Nevada US
  • Status: Offline

Post October 25th, 2009, 10:05 am

Code: [ Select ]
$num=mysql_num_rows($result);
if($num==0){
echo "Message!";
}else{
echo "Result Set";
}
  1. $num=mysql_num_rows($result);
  2. if($num==0){
  3. echo "Message!";
  4. }else{
  5. echo "Result Set";
  6. }
  • George L.
  • Bronze Member
  • Bronze Member
  • No Avatar
  • Joined: Nov 05, 2007
  • Posts: 2206
  • Loc: Malaysia
  • Status: Offline

Post October 25th, 2009, 4:08 pm

I don't think it will work, Flanders, empty set from MySQL doesn't represent NULL, false or 0..

Did you try that??...

Anyway I have decided to just put an error message by default..

There seems to be a way to do it using mysqli_etc. etc. etc...

I didn't do it cuz of time running out..

Thanks anyway...
  • onlyican.com
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Nov 20, 2005
  • Posts: 1589
  • Loc: Hants, UK
  • Status: Offline

Post October 27th, 2009, 9:40 am

empty set my not represent null, 0, false but num_rows would.
Heal your mind, and the body will follow

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 111 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.