Questions tagged [mysql-num-rows]

Retrieves the number of rows from a result set.

mysql_num_rows($resultSet) is used to retrieve the number of rows in $resultSet.

It should only be used on a result set generated from a query that produces an actual set of results, such as SELECT. If you want to get the number of rows affected by an UPDATE, DELETE, or INSERT, you should use mysql_affected_rows instead.

It will return the number of rows in the rowset; or boolean FALSE on failure.

Note that as of PHP 5.5.0, this function has been deprecated.

181 questions
0
votes
1 answer

Usage of mysql_num_rows inside a While loop

I have a query selecting a group of matching elements, and then a If condition ckecking if one (or more) of those matching elements are valid, depending on what they contain on a couple of DATE fields. This works…
Biomehanika
  • 1,530
  • 1
  • 17
  • 45
0
votes
0 answers

affected_rows may return 0, 1, -1, 3 or in some scenarios NULL [Suggested Answer]

The PHP documentation contains the reasons why an affected_rows statement might return 0, 1, -1 or even 3 in some scenarios, as does the answer to this particular stack question. PHP / MySQLI: strange readings for affected_rows But the wall I hit…
0
votes
3 answers

mysql_num_rows if count is greater than 1

I'm using Mysql_num_rows to fetch data (their email & IP), if it's already been input by said user then it will decline, but if it hasn't then it succeeds. However, if I change my IP it still successes, when it shouldn't because im using the same…
Arylis
  • 5
  • 1
  • 4
0
votes
1 answer

use mysql_num_rows for two tables

I have a problem with mysql duplication. I have two tables name as student and temp_student. Both tables have same fields except for temp_student, i've add studentStatus and statusNote. The problem is, when I use mysql_num_rows for any tables to…
0
votes
1 answer

Number of items per category in sql table

How do i find how many items there are per unique user in a data base So say i have hats gloves and lots of other elements in my data base that users have added how would i find how much each one had e.g. hats- 35 t-shirts -50 but the problem is the…
0
votes
2 answers

Foreach inside While Statement (NumRows)

I'm trying to figure out how I would do a foreach statement inside my while statement. As you can tell by this code, it will only submit 1 row out of the table, even though it selects all the rows. How would I make it select each row? Code: $q2 =…
user3023566
  • 159
  • 1
  • 1
  • 12
0
votes
3 answers

PHP MYSQL select * with this value with between these dates

I'm trying to select a list of customers that have entered a specific voucher code, within certain dates. Here is my code with my latest attempt: $result = mysql_query( "SELECT COUNT(members.voucher_code) FROM members WHERE…
Connor
  • 3
  • 3
0
votes
2 answers

PHP / MySQLi / login script

Apologies I know this is going to be a simple answer most likely, but looking for answers I think its confusing me more than just asking the question as there are so many, with confusing or sometimes contradictory answers. My login script is working…
ablueman
  • 145
  • 1
  • 3
  • 13
0
votes
5 answers

MySQL num_rows doesnt return value (SELECT INTO)

When I run this code in PHP the values are returned correctly $result = $mysqli->query("SELECT `id`, `last_key_ID` FROM `customers` WHERE `email` = '{$email}';"); But as soon as I add the INTO-syntax to it, the num_rows returns no value: $result =…
user3160134
  • 199
  • 11
0
votes
1 answer

..->num_rows showing wrong result

I have created a function in PHP that checks if a record is existing in the database or not. The query I am using to get the row is: SELECT COUNT(*) AS Total, Conversation_ID FROM conversation WHERE User_ID = 3 AND With_User_ID = 4 Now, when I run…
Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113
0
votes
2 answers

I get an annoying error on my login system

I am trying to make a login system for my website but there is an error comming every time i run it that says: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\login_system\includes\login.php on line…
Anton Bahrencheer
  • 41
  • 1
  • 1
  • 10
0
votes
2 answers

Why my sql php logic return false output?

Hello I have this code and I have a problem at function evalLoggedUser I think...as it is now the function shows me wrong output(returning false instead true) and when I change the if statement inside the function and do it like this: if($numrows ==…
Vaios P.
  • 404
  • 8
  • 23
0
votes
1 answer
0
votes
1 answer

Running a PDO mysql_num_rows query

How do I run this as a PDO query? $query = "SELECT * FROM `Top_10` WHERE DOB =". $date; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result)==0){ while blah blah } I can run the PDO fetch array. But as soon as I do this,…
0
votes
1 answer

Can not figure out why mysqli_num_rows is not working on my query

function userexists($username){ $query=$mysqli->query("SELECT username FROM accounts WHERE username='$username' AND exists=1"); return mysqli_num_rows($query); } This function should be returning 1 or 0 but I can not figure out why the…
user1755043
  • 281
  • 1
  • 13