For some reason this bit of code: <? $_GET['offer']=strip_tags($_GET['offer']); $_GET['offer']=mysql_real_escape_string($_GET['offer']); $type="free"; $getoffers=mysql_query("select * from offers where `type`='$type' and active=1 order by reward desc",$c); if(mysql_num_rows($getoffers)==0) //ERROR LINE { print"<tr><td colspan=\"3\">There are currently no free offers available</td></tr>"; } ?> Code (markup): is producing the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path/to/public_html/domain/offers.php on line ### Code (markup): The same error is coming up in other parts of my script using the mysql_num_rows() function. I am thinking that it has to do with the PHP version, but cannot be sure. If anyone can help me out it would be immensely appreciated!!
After query add line: echo mysql_error(); PHP: and tell us what it shows. If nothing then try var_dump($getoffers); PHP: and paste result here. We need something to work with, to help you out.
Don't take this the wrong way but this code is a mess... try this instead. $offer=mysql_real_escape_string(strip_tags($_GET['offer'])); $type="free"; $query = "select * from offers where type='$type' and active=1 order by reward desc"; $sql = mysql_query($query); $availableoffers = mysql_num_rows($sql); if($availableoffers){ // do whatever if offers exist. }else{ print"<tr><td colspan=\"3\">There are currently no free offers available</td></tr>"; }
<? $offer = $_GET['offer']; $strip_offer=strip_tags($offer); $escape_offer=mysql_real_escape_string($strip_offer); /* Now you can user your offer value from $escape_offer variable */ $type="free"; $getoffers=mysql_query("select * from offers where type='$type' and active=1 order by reward desc",$c); if(mysql_num_rows($getoffers)==0) //ERROR LINE { print"<tr><td colspan=\"3\">There are currently no free offers available</td></tr>"; } ?> PHP:
How dare you! Just kidding. I know my code could be cleaned up a bit. Nasty old habits. Also, thanks to all for the input. Problem has been resolved.
I'm not quite sure since I'm not the one that fixed it lol. However, I did notice that the type was still in quotation marks, if that is something you're wondering about lol