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
1
vote
2 answers

Order MySQL results by number of related rows in foreign table

Alright, so I have a table outputting data from a MySQL table in a while loop. Well one of the columns it outputs isn't stored statically in the table, instead it's the sum of how many times it appears in a different MySQL table. Sorry I'm not sure…
Rob
  • 7,980
  • 30
  • 75
  • 115
1
vote
1 answer

mysql_num_rows() expects parameter 1 to be resource, boolean

I keep getting this error: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u592632722/public_html/profile.php on line 80 I cant figure out how to solve it. This is my profile.php code:
user3738431
1
vote
0 answers

Prepared statement and counting

Anyone has any idea how to count the amount of rows retrieved? It should only be 1 in this case- but I just can't seem to make it work with prepared statements (still very new to using it) Thanks in advance for any help! if ($stmt =…
1
vote
3 answers

$result->num_rows always returns 0

after reading tons of threads, tutorials and whatever - I feel like posting here and hope that someone can help me. I tried out every advice I could get, but it's still not working. Here is my code : $prep_stmt = "SELECT id,…
Kris
  • 567
  • 3
  • 11
  • 25
1
vote
2 answers

mysql_num_rows and condition

Hi guys I am trying to use something more efficient instead of using mysql_num_rows from multiple queries. Am I able to use one query and for example count mysql_num_rows() based on condition if $type=="a"? And declare variable for each.. for b…
Karim Ali
  • 61
  • 2
  • 10
1
vote
2 answers

PHP: How to check if no rows are returned

With the following PHP code, how do i check if there's no row retuned so i can echo some message? PHP:
Relm
  • 7,923
  • 18
  • 66
  • 113
1
vote
3 answers

mysql_num_rows() expects parameter 1 to be resource error

Can someone help me to solve this error: mysql_num_rows() expects parameter 1 to be resource This is my code: $query = mysql_query($query); $numrows = mysql_num_rows($query); if ($numrows > 0){
JessieNBarnes
  • 53
  • 1
  • 1
  • 7
1
vote
2 answers

mysql and php login page with mysql_num_rows

I have those codes and its give me an error 'Warning: mysql_num_rows() expects parameter 1 to be resource' : PHP:
Ben Ben-Hamo
  • 765
  • 1
  • 5
  • 6
1
vote
2 answers

PHP: Trying to get property of non-object

I am working on a function, what returns whether a table exists or not. But it always notices: Notice: Trying to get property of non-object [...] on line 10 in 1 function table_exists($table) { 2 3 // get the database 4 global…
Julius Rickert
  • 410
  • 3
  • 13
1
vote
1 answer

How get number of rows result a query in SQL (C ANSI)?

I need get the number of row result a query in SQLite in C Example: SELECT name, age FROM test WHERE age > 18 How i can get the number of rows this query in SQLite C. I see the command sqlite3_total_changes() to affected row (When use INSERT,…
Sileno Brito
  • 449
  • 1
  • 13
  • 31
1
vote
4 answers

SHOW TABLES and MYSQL_NUM_ROWS

I have just noticed that where mysql_num_rows should return the number of rows returned for either SELECT or SHOW commands, returns 0 for SHOW TABLE command specifically. Instead it shows the affected rows count instead of the num rows. Can anyone…
Vish
  • 4,508
  • 10
  • 42
  • 74
1
vote
4 answers

Is using mysql_num_rows (rowCount in PDO) necessary in update or insert query?

Should I be using mysql_num_rows (rowCount in PDO) in update or insert query? Currently, my code looks likes this, public function update_username(){ $q = "UPDATE usertable SET username = '$user_name' WHERE id = '$user_id' LIMIT 1"; $r =…
Peter
  • 141
  • 4
  • 11
1
vote
1 answer

How can you use CASE Statements to assign values to matches in your query?

Let's say your running a query and you have a lot of different user inputs that may not find an exact match. Now would it be possible to do something like the following? $query = "SELECT *, CASE matchingValues WHEN…
CWF010
  • 55
  • 3
1
vote
2 answers

MySQL- Left Join shows more rows than expected

I'm joinning two SELECTS. The first one retrieves: t1 id value 1 149 2 149 3 149 4 149 The second one: t2 id value 149 2 149 13 149 145 149 149 So, I'm joining t1/t2 on t1.value = t2.id. But the outcome follows: 1 149 2 1 149 13 1 …
Cristobal
  • 23
  • 3
1
vote
3 answers

Using Inner Join and mysql_num_rows() is Always returning 1 less row

I checked throught the existing topics. I have a fix for my problem but I know its not the right fix and I'm more interested making this work right, than creating a workaround it. I have a project where I have 3 tables, diagnosis, visits, and…
Binxalot
  • 41
  • 7