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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
highaspen Posted September 23, 2006 Author Share Posted September 23, 2006 You're a God... thanks. Quote Link to comment 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 :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.