SirChick Posted November 5, 2007 Share Posted November 5, 2007 I have two mysql_num_rows for one query in different places but only one of them is producing error =/ it doesn't make much sense this is what i have: $MobileLock = mysql_query("SELECT * FROM useritem WHERE ItemID='2' AND UserID='{$_SESSION['Current_User']}'") Or die(mysql_error()); //this works fine If(mysql_num_rows($MobileLock) == 0){ header("location: myhouseinfo.php"); }Else{do something} But i do the same num rows comment further in my script and it gives me this: <b>Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource in <b>C:\xampp\htdocs\myphone.php</b> on line <b>84</b><br /> This is line 84: if(mysql_num_rows($MobileLock) == 0){}Else{do stuff} completely identical =/ what did i do wrong? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 5, 2007 Share Posted November 5, 2007 Your $MovileLock variable could be out of scope. Post more of your code so we can see if thats the problem. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 5, 2007 Author Share Posted November 5, 2007 i assigned num rows to variables to see if it would help but didnt seem to so heres the script: What do you mean by out of scope i would have though it applies through the entire script? $MobileLock = mysql_query("SELECT * FROM useritem WHERE ItemID='2' AND UserID='{$_SESSION['Current_User']}'") Or die(mysql_error()); $mobilecount = mysql_num_rows($MobileLock); If($mobilecount == 0){ header("location: myhouseinfo.php"); }Else{ $mobilelockrow = mysql_fetch_assoc($MobileLock); $MobileOff = $mobilelockrow['PhoneLock']; } include("londonpagesinclude.php"); $FindTexts = mysql_query("SELECT * FROM textmessages WHERE Receiver='{$_SESSION['Current_User']}' And Status='0'") or die(mysql_error()); $Textnumrows = mysql_num_rows($FindTexts); if($mobilecount == 0){}Else{ Echo 'stuff'; If ($Textnumrows == 0){ Echo 'stuff2'; }Else{ Echo'stuff3'; Echo $Textnumrows; Echo' total message(s). Max capacity is 5.</b></u></b></font></div> '; } ?> <div id="bv_" style="position:absolute;left:383px;top:756px;width:177px;height:16px;z-index:13" align="center"> <font style="font-size:13px" color="#000000" face="Arial"><b><u><a href="sendtext.php">Send Text Message</u></b></font></div> <? if ($Textnumrows == 0) {}Else{ Echo'<div id="bv_" style="position:absolute;left:655px;top:756px;width:166px;height:16px;z-index:14" align="center"> <font style="font-size:13px" color="#000000" face="Arial"><b><u><a href="checktexts.php">Check Text Messages</a></u></b></font></div> '; } If ($MobileOff == 0){ Echo'<div id="bv_" style="position:absolute;left:120px;top:757px;width:150px;height:16px;z-index:15" align="center"> <font style="font-size:13px" color="#000000" face="Arial"><b><u><a href="mobilephoneprocess.php">Turn Off Mobile</a></u></b></font></div> '; }Else{ Echo'<div id="bv_" style="position:absolute;left:120px;top:757px;width:150px;height:16px;z-index:15" align="center"> <font style="font-size:13px" color="#000000" face="Arial"><b><u><a href="mobilephoneprocess.php">Turn On Mobile</a></u></b></font></div> '; } } 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.