473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

unknown result resource with mysql_num_rows

The1corrupted
134 100+
Okay, this has blown my entire perception of reality way out of order. First, a page was working and not five minutes later, I get this error,


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Vardaes\gendisp.php on line 66

and I made insignificant changes to the script before hand that had nothing to do with mysql_num_rows();...

Here's line 66
[PHP]
$saynum=mysql_num_rows(mysql_query("SELECT `cn` FROM `user_table` WHERE `cn`='$mesgread[2]' AND `ns`=$x AND `ew`=$y AND `ud`=$z"));
[/PHP]
Mar 6 '07 #1
3 1573
ronverdonk
4,258 Expert 4TB
When the select fails for whatever reason you do not get an object to query the no of rows. So it is better to run the query first and capture the errors and only then get the row count. Like this:

Expand|Select|Wrap|Line Numbers
  1. $res = mysql_query("SELECT `cn` FROM `user_table` 
  2.                     WHERE cn`='$mesgread[2]' 
  3.                     AND `ns`=$x 
  4.                     AND `ew`=$y 
  5.                     AND `ud`=$z");
  6.    or die ("Select error: ".mysql_error());
  7. $saynum=mysql_num_rows($res); 
Ronald :cool:
Mar 6 '07 #2
The1corrupted
134 100+
Thanks, and I've found the errors so everything's working fine now.
Mar 6 '07 #3
ronverdonk
4,258 Expert 4TB
You are welcome any time.

Ronald :cool:
Mar 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...
2
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item,...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
2
by: 00webman | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15 Can anyone spot my error?!? Thanks. <?php # Script 7.6 -...
2
by: studentfromhell | last post by:
These mesages appeared... what should I do? script is below the error messages... Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
3
by: JRough | last post by:
I want to save two variables in a $_SESSION for use in another page: $_SESSION = $mark; $_SESSION = $num; then on the other page I did this to get the value: $mark =$_SESSION; $num =...
3
nomad
by: nomad | last post by:
Hello everyone: I new to PHP and I'm reading a book on PHP Bibles 2nd edition. It has to deal with a user-rating system. There are 4 scripts to it. I'm getting an error Unknown column...
2
by: macdalor | last post by:
Hi! I'm completely new to all dev and trying to put a website together using MySQLI and PHP; was running fine until I try to gather the DB content with the following script: <?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.