Jump to content

Recommended Posts

:confused: 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

Link to comment
https://forums.phpfreaks.com/topic/252660-count-rows/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295257
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/252660-count-rows/#findComment-1295263
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.