highaspen Posted September 23, 2006 Share Posted September 23, 2006 okay, I've tried writting this several different ways each not working. I'm sure it's something stupid. Here is what I've got.------------------------$rs=mysql_query($sql,$conn) or die("Could not execute query"); if (!$rs){include ("somepage.php");exit();}else{ then I've got a bunch of code here. }------------------------The problem I'm having is, the if statment is continually ignored and only displays the else. I've rigged the database so that the if statment will be true, yet it still fails. I've also tried this using if ($rs == "null") with the same results. And if($rs==NULL).Any help would place the helper in GOD status in my mind.Thanks Link to comment https://forums.phpfreaks.com/topic/21792-if-statement-hair-pull-out-solved/ Share on other sites More sharing options...
Barand Posted September 23, 2006 Share Posted September 23, 2006 mysql_query only returns false if the query fails beacause of an error.Are you expecting $rs to be false because no records are returned. Returning no records is not an error. To check that condition you need[code]<?php$rs=mysql_query($sql,$conn) or die("Could not execute query"); if (mysql_num_rows($rs)==0){ include ("somepage.php"); exit();}else { // then I've got a bunch of code here. }?>[/code] Link to comment https://forums.phpfreaks.com/topic/21792-if-statement-hair-pull-out-solved/#findComment-97324 Share on other sites More sharing options...
highaspen Posted September 23, 2006 Author Share Posted September 23, 2006 You're a God... thanks. Link to comment https://forums.phpfreaks.com/topic/21792-if-statement-hair-pull-out-solved/#findComment-97328 Share on other sites More sharing options...
Barand Posted September 23, 2006 Share Posted September 23, 2006 The only ambrosia I get to eat is rice pudding :) Link to comment https://forums.phpfreaks.com/topic/21792-if-statement-hair-pull-out-solved/#findComment-97335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.