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
2
votes
2 answers

MySQL mysql_num_rows();

I am not sure as to why. But the code I have created below is not working. The variable: "$num_rows" is not even being set and has no value (not even 0). Anyone know as to why this issue is occurring? $result2 = mysql_query("SELECT * FROM…
wesslayneb
  • 47
  • 1
  • 1
  • 8
2
votes
3 answers

PHP MySQLi Prepare Statement Failing to return rows

I have been converting a lot of my old MySQL stuff to MySQLi in PHP and am getting a problem on the following code: ### FETCH INCLUDES ### $player=$_POST['player']; $password=md5($_POST['password']); #### DB CONNECTION #### if(!$mysqli=new…
elzaer
  • 729
  • 7
  • 25
2
votes
2 answers

sql Showing rows 0 - 0 (1 total) causing error with mysql_num_rows

right i have confirmed the query SELECT * FROM mbgeust WHERE user_name = '{$name}' AND user_pass = SHA1('{$pass}') returns a result but it returns saying 'Showing rows 0 - 0 ( 1 total, Query took 0.0005 sec)' sould that not be rows 0 - 1 as…
1
vote
1 answer

Reading file contents and appending a string to it - SQL Errors and mysql errors

When I run my code I'm facing the next 2 errors: mysql_num_rows() expects parameter 1 to be resource, boolean That happens at rare lines of the file. Rest of them works just fine. You have an error in your SQL syntax; check the manual that …
Kishor
  • 1,513
  • 2
  • 15
  • 25
1
vote
3 answers

mysql_num_rows in an if statement

The problem I am facing is, mysql_num_rows gives me an output of 1 all through out the code, but when I match it wil 0 in an if statement, it returns true and does the code. so $license returns ........ instead of its actual value. I tried to debug…
Kishor
  • 1,513
  • 2
  • 15
  • 25
1
vote
2 answers

PHP login system issue - mysql_num_rows is not valid

UPDATE: changed some sql queries and now it transfers to the control panel. Although it shows these error. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at…
AisRuss
  • 259
  • 4
  • 8
  • 16
1
vote
5 answers

MySQL & PHP - Only list items not listed previously

Sorry the title is very vague. Basically, I'm stuck with something. I have an ample working script which lists from two tables. It pulls a list of events Event 1 Event 2 Event 3 Event 4 Event 5 Event 6 Now, users need t-shirts for the "overall"…
TheMonk
  • 13
  • 3
1
vote
4 answers

PHP mysql_num_rows "no results" message?

I have a MySQL keyword search on my website and it works fine. The problem is when someone searches a keyword I haven't added, nothing shows up on the results page. Instead of nothing showing up I would like to have a no results found message. So…
Will
  • 33
  • 2
  • 8
1
vote
1 answer

PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

I'm creating a CRUD for an Inventory Database. Upon loading the index.php my error_log returns the following: PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home1/theantj4/public_html/crud/index.php on…
1
vote
2 answers

Codeigniter get number of row from search query

I have a query in my controller which searches for the term/keyword that is in the url. Example /search/keyword Then through my controller I perform the search doing: $viewdata['search_results'] =…
hairynuggets
  • 3,191
  • 22
  • 55
  • 90
1
vote
1 answer

Implementing pagination in codeigniter, can't get count

I am having difficulties implementing the codeigniter pagination class. I have created my model, view and controller for getting my news articles and data is echoed in the view successfully. My problem is that when I attempt to implement pagination…
hairynuggets
  • 3,191
  • 22
  • 55
  • 90
1
vote
1 answer

Strange Database problem! PHP MySQL Codeigniter

I am experiencing a strange problem with a simple query that returned the number of rows in a table. This was always working fine and correct. However! Yesterday I added a new function to my website that updates a column in existing rows in my…
sqlmole
  • 997
  • 7
  • 17
  • 31
1
vote
3 answers

problem with mysql_num_rows

Here is my code : $sql1 = 'SELECT * FROM login WHERE age= "$age", town = "$town" and ID != "$id"'; $result1 = mysql_query($sql1); $numResults1 = mysql_num_rows($result1); My variables are fine, they have data in them. The error is this :…
Niall Paterson
  • 3,580
  • 3
  • 29
  • 37
1
vote
3 answers

while ($row=mysql_fetch_array($query)) is not working

What i try to do is check the user's Id by verifying in a cookie (called "identification"). thats my code: if(!$noCookie) { $sql = "SELECT * FROM `". TABLE_PREFIX ."_logged` WHERE `logged_cookie` = '". $usersCookie ."' LIMIT 1"; $query =…
Elron
  • 11
  • 1
  • 2
1
vote
5 answers

Using mysql_num_rows(), how do I tell whether myql_query() has returned a result of 0 or an sql error in php

Using php I understand that false is the same as 0, so when checking my select query results, if I have 0 results mysql_num_rows($result) will evaluate to false - this i understand, what will the function evaluate to if I have an sql…
Amanda
  • 11
  • 1
  • 2
1
2
3
12 13