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
0 answers

What is the most reliable way to check if a successful MySQL query has returned no results?

I want to check if a successful query has returned no results. When testing this script locally, I make sure that the database does not contain any values the query is seeking, but mysqli_num_rows($res) != 0 returns true. mysqli_num_rows($res)…
Callum
  • 315
  • 4
  • 18
0
votes
2 answers

num_rows always gives back that there are no rows (that are equal to my input) in the database which isn't true

I'm trying to find out if the title someone filled in in a form is already in the database (cause otherwise I'm going to add a number to the title). But somehow the code underneath always give back "doesn't exists". [my_table_name] is of course…
0
votes
1 answer

Check whether there is an entry in a result from mysql_query via php

I'm very new here as well as in php and mysql and I hope you can help me :) I'm trying to build a JSON for a visualization using data from a database. My problem is, that it doesn't passes the if-request. In the while-loop the data should be used…
Maki
  • 109
  • 13
0
votes
4 answers

php + mysql_num_rows

is there a more efficient way of doing the following? $total_a = mysql_query("SELECT `id` FROM `table` WHERE `this` = 'that'"); $total_b = mysql_num_rows($total_a); if(!$total_b) { echo 'no results'; } else { $a = mysql_query("SELECT `id`,…
user317005
0
votes
1 answer

mysql_num_rows gives waring when no data found in database

I have a query which perform fine, but the problem is somehow its gives me the warning when no data match from database. $count = mysql_num_rows($qry); //warning here I can use @ to hide the error, but this is not good programming as far i know,…
user6364857
0
votes
3 answers

Password Changer [Warning: mysql_num_rows() expects parameter 1 to be resource]

Possible Duplicate: mysql_num_rows(): supplied argument is not a valid MySQL result resource I am using simple self-created php script to change password to my wow server's website. Here's the error: "Warning: mysql_num_rows() expects …
Lazy Guy
  • 3
  • 2
0
votes
2 answers

num row isnt detecting row in table

I'am currently making a login system for news website as part of my coursework. For some reason when I use $rows->num_rows == 1 in an if statement, it always runs the "else" code. Basically this means that it doesnt detect a row in my table that…
Kent Godfrey
  • 83
  • 1
  • 3
  • 12
0
votes
1 answer

fetchColumn error on PDO while trying to get number of rows

I'm trying to move to PDO. I want to do a classic query for checking number of rows, in mysql I would have done mysql_num_rows_result but I've read somewhere that in PDO it does not work. So I've tried with a fetch column using the following code…
Stanislas Piotrowski
  • 2,595
  • 10
  • 40
  • 59
0
votes
2 answers

mysql_num_rows returns 0, but the same query in phpMyAdmin return results

We have been working for a few hours on a serious problem. We have the following code: mysql_connect("localhost","xxx","xxx") or die(mysql_error()); mysql_select_db("xxxe"); $q = "SELECT m.id, m.expired_date, u.email FROM jos_osemsc_member m,…
Florian
  • 71
  • 8
0
votes
5 answers

mysql_num_rows for an mysql object?

How do I find mysql_num_rows for an object. This gives an error: $query = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_object($query); echo mysql_num_rows( $row ); Warning: mysql_num_rows() expects parameter 1 to be…
ganjan
  • 7,356
  • 24
  • 82
  • 133
0
votes
6 answers

Select the latest version based on date for each ID in MYSQL

I have a table like: +------------+-------------------+--------------+------------+ | listing_id | transaction_title | image_thumb | sale_date | +------------+-------------------+--------------+------------+ | 226835186 | Title Version 11 | Img…
Acidon
  • 1,294
  • 4
  • 23
  • 44
0
votes
1 answer

Num Rows always ='s 1 for some reason. QUICK FIX

I don't know if i am doing it right, this is what I got: while($row = mysqli_fetch_assoc($result)) { $items = mysqli_num_rows($row); } It always sets $items = to 1 for some reason. Here is my mysqli_query... $top10_query = "SELECT * FROM…
Rick Bross
  • 1,060
  • 3
  • 16
  • 39
0
votes
1 answer

Mysql Query "OR" and "AND"

$assault_checker=mysql_query("SELECT * FROM assaults WHERE host_id='".$_SESSION['user']."' OR guest_id='".$_SESSION['user']."' AND status='0'"); $assault_checker=mysql_num_rows($assault_checker); I keep getting the wrong expected result. I just…
0
votes
1 answer

MySQL Numrows Expecting Parameter

So I'm Getting The Error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\All Connected\profile.php on line 117 While Try To Check For Friend Request Status Information, I Have Seen People Fix This…
0
votes
1 answer

num_rows return ZERO all the time in CodeIgniter

I have a simple code in CI Model for Login BUT it always return 0. $this->db->select('*'); $this->db->from('cms_users'); $this->db->where('username', "admin"); $this->db->where('password', "admin01"); $query =…
Methew
  • 359
  • 4
  • 10
  • 28