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

  • George L.
  • Bronze Member
  • Bronze Member
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Posts: 48
  • Loc: Reno, Nevada US

Post 3+ Months Ago

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
  • George L.
  • Posts: 2209
  • Loc: Malaysia

Post 3+ Months Ago

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
  • Posts: 1589
  • Loc: Hants, UK

Post 3+ Months Ago

empty set my not represent null, 0, false but num_rows would.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 80 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.