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
8
votes
4 answers

With mysql_fetch_array I can easily count the rows returned. Can I do something similar with mysql_fetch_object?

(Apologies if necessary--my first Stack Overflow question. I'll be happy to modify it if anyone has suggestions. I have looked for an answer but I'm afraid my grasp of the terminology isn't good enough to make a complete search.) I'm accustomed to…
David Rhoden
  • 913
  • 5
  • 15
  • 30
7
votes
1 answer

mysql_num_rows in laravel?

im trying to use mysql_num_rows in laravel but laravel says it not the same way like in 'raw php' example: $users = DB::table('users') ->where('username', '=', $username) ->where('password', '=', $password) …
indian
  • 75
  • 1
  • 1
  • 5
6
votes
2 answers

mysql_num_rows() php - is it efficient?

I have several SELECT statements on a PHP page, and I used Dreamweaver to generate those. After going through the code it generated, there seemed to be alot of fluff which I could cut out under most circumstances, a mysql_num_rows() line for each…
totallyNotLizards
  • 8,489
  • 9
  • 51
  • 85
6
votes
2 answers

mysqli_stmt_num_rows($stmt) always returns 0?

I am creating a login script for my web app and am trying to use $count = mysqli_stmt_num_rows($stmt); to find the number of rows returned from the sql select statement, so I can then decide if a session should be started. The problem is, $count is…
Corey
  • 327
  • 5
  • 15
5
votes
2 answers

PHP- mysqli->num_rows always returns 0, Prepared statements

First of all I would like to tell that I have already gone though ALL DUPLICATE questions. and tried the changes suggested there. As far as now I have already tried changing num_rows to num_rows() And using store_result(); And using…
4
votes
2 answers

Checking if email exists in the database?

I have this function or method in my class, but it doesn't return number of rows when I insert an email into it. I have tested the mysql connection etc, they all are working. Also note that the email that I am passing through the method already…
Sokhrat Sikar
  • 175
  • 3
  • 4
  • 14
4
votes
3 answers

How to check if mysql_query returned anything or not

Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, boolean given in select So I am trying to check if the following query returns any result or not $numUsersSameRatingQuery="SELECT * `user ratings` WHERE …
user945221
3
votes
3 answers

mysql_num_rows isn't returning any rows

So, I have some code. I know that mysql_num_rows is deprecated, but since I've already used it I don't want to switch everything to mysqli_. Anyway it was working on my local server and returning 1 or more results based on the entry. This is a PHP…
3
votes
4 answers

Does a user id have to be an integer?

This is probably a repeated question but I really can't find any answers. I have a forgotten password script which grabs the users email address from the URL using $_GET. The script then checks the $_GET for error messages then passes through to…
2
votes
2 answers

mysql_fetch_array returning false when mysql_num_rows says that there is data, why?

my table has 10 records, and mysql_num_rows says that there are 10 rows in the mysql resource, in phpMyAdmin I can see 10 rows, but when mysql_fetch_array is called, the first two times this works correctly, then the last 8 times it returns…
user1300867
2
votes
2 answers

Num rows returns wrong number

Im trying to count the rows where there are 0 rows, but it return 1 row anyways, when there are no rows that matches the SQL query. Does anyone know what im doing wrong? $del = mysql_real_escape_string(strip_tags($_GET['del'])); if…
Kaizokupuffball
  • 2,703
  • 8
  • 38
  • 58
2
votes
5 answers

Proper way to ask if mysql_num_rows in PHP

Because mysql_num_rows returns false if there are no rows returned, would it be best to do: $query = mysql_query("SELECT id FROM table WHERE something = 'this'"); $result = mysql_num_rows($query); if ($result) { } Or should I do: if ($result >=…
Oseer
  • 740
  • 7
  • 19
  • 28
2
votes
2 answers

PHP and MySQL: Number of rows returned

How can I see how many rows the following query returns? mysql_select_db($database_aoldatabase, $aoldatabase); $query1 = "select * from sale where secid = $invoiceno "; $query2 = "select * from sale where secid = $invoiceno "; $maxa =…
tee
  • 155
  • 2
  • 6
  • 12
2
votes
4 answers

mysql_num_rows always returns 1

The result is always 1: $sql = 'SELECT COUNT(Vote) FROM ' . $table; $res = mysql_query($sql, $conn); $vote_total = mysql_num_rows($res); I ran the $sql query in phpMyAdmin and it returns 3, so the query is not the problem. $vote_total is…
NightHawk
  • 3,633
  • 8
  • 37
  • 56
2
votes
0 answers

mysqli_num_rows works with value but returns error when empty

I try to create an if / else action, based on the number of rows in my DB. $gekoppeldeDB = $_POST['gekoppeldeDB']; $sql_bon = mysqli_query($mysqli, "SELECT * FROM $gekoppeldeDB"); $rowcount = mysqli_num_rows($sql_bon); echo ($rowcount); when…
Jeffrey van Zwam
  • 105
  • 1
  • 15
1
2 3
12 13