pranshu82202 Posted December 7, 2011 Share Posted December 7, 2011 Can any one tell me whats the best ( actually error free ) which i can use to count the number of rows finally resulting after select command. I use this ... $sql = mysql_query("select * from usname where name1='$name1' and name2='$name2' and amm='$amm'"); $num=mysql_num_rows($sql); echo $num; But it always gives the same error.... and the error is.......... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\money\insert.php on line 20 where line 20 is... $num=mysql_num_rows($sql); - Pranshu Agrawal pranshu.a.11@gmail.com Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 7, 2011 Share Posted December 7, 2011 That error, for the posted code, means that the query failed due to an error of some kind (connection problem, sql syntax error, wrong table/column names, un-escaped string data being put into the query statement.) You would need to troubleshoot why the query is failing. You can echo mysql_error(); to get php/mysql to tell you why the query is failing. Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295257 Share on other sites More sharing options...
pranshu82202 Posted December 7, 2011 Author Share Posted December 7, 2011 Thanks PFMaBiSmAd, I got the issue ..... actually the table name i am using is not correct............ Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295259 Share on other sites More sharing options...
ManiacDan Posted December 7, 2011 Share Posted December 7, 2011 Thanks PFMaBiSmAd, I got the issue ..... actually the table name i am using is not correct............ Thanks for the help The logic isn't correct either. You probably want where name = 'name1' OR name = 'name2'. A single field can never be the same as two different things. Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295263 Share on other sites More sharing options...
pranshu82202 Posted December 7, 2011 Author Share Posted December 7, 2011 Maniac Dan you didnt got it correctly........ There i have written "where name1='$name1' and name2='$name2'........" Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295340 Share on other sites More sharing options...
ManiacDan Posted December 7, 2011 Share Posted December 7, 2011 Ah you're right, I didn't notice. Quote Link to comment https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295350 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.