esandra Posted September 14, 2010 Share Posted September 14, 2010 ive had these queries working okay until i checked on it today, it's not working anymore.. these are the errors::: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\arrastre\add.php on line 105 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\arrastre\add.php on line 117 if(isset($_POST['add'])){ if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $total=="" or $date=="" or $tcl==""){ echo "At least one field was left blank."; } else{ $query = mysql_query("select * from `arrastre` WHERE `billnmbr`='$billnmbr'"); /*****************this is my line 105************/ $count = mysql_num_rows($query); if($count==1){ echo "This billnumber is already in the database."; } else{ $bll = strtoupper($billnmbr); $payr = strtoupper($payor); $query="insert into `arrastre` (`billnmbr`, `orno`, `payor`, `arrastre`, `wharfage`, `total`, `date`, `tcl`) values ('$bll', '$orno', '$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl')"; $result=mysql_query($query); $query = mysql_query("select * from `arrastre` where `billnmbr`= '$billnmbr'", $link); /************and this is my line 117*************/ $count = mysql_num_rows($query); if($count==1){ echo "last bill number added: ".$billnmbr; } } Thank you very much for your time and have a nice day. Quote Link to comment https://forums.phpfreaks.com/topic/213347-can-somebody-please-look-at-my-queries/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2010 Share Posted September 14, 2010 Your queries are failing due to some kind of error and assuming you have not changed your code, it is likely a problem with the database server, with your database, or with your table. If you echo mysql_error(); on the next line after the line with your mysql_query() statements, it will tell you why the query(ies) are failing. Quote Link to comment https://forums.phpfreaks.com/topic/213347-can-somebody-please-look-at-my-queries/#findComment-1110808 Share on other sites More sharing options...
Mod-Jay Posted September 14, 2010 Share Posted September 14, 2010 Try This if(isset($_POST['add'])){ if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $total=="" or $date=="" or $tcl==""){ echo "At least one field was left blank."; } else{ $query = mysql_query("SELECT billnmbr FROM arrastre WHERE billnmbr='$billnmbr'"); /*****************this is my line 105************/ $count = mysql_num_rows($query); if($count==1){ echo "This billnumber is already in the database."; } else{ $bll = strtoupper($billnmbr); $payr = strtoupper($payor); $query="insert into `arrastre` (`billnmbr`, `orno`, `payor`, `arrastre`, `wharfage`, `total`, `date`, `tcl`) values ('$bll', '$orno', '$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl')"; $result=mysql_query($query); $query = mysql_query("SELECT billnmbr='$billnmbr' FROM arrastre WHERE billnmbr='$billnmbr'", $link); /************and this is my line 117*************/ $count = mysql_num_rows($query); if($count==1){ echo "last bill number added: ".$billnmbr; } } OR Add or die(mysql_error()) ; Thats at the End of Both Quote Link to comment https://forums.phpfreaks.com/topic/213347-can-somebody-please-look-at-my-queries/#findComment-1110810 Share on other sites More sharing options...
Pikachu2000 Posted September 14, 2010 Share Posted September 14, 2010 Off topic slightly, but if all you need to do is return the number of times the number appears in the database, SELECT COUNT(`billmnbr`) AS num would be much more efficient than using mysql_num_rows(). Quote Link to comment https://forums.phpfreaks.com/topic/213347-can-somebody-please-look-at-my-queries/#findComment-1110823 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.