473,385 Members | 1,396 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,385 software developers and data experts.

Mysql_Num_Rows Error in PHP Script

35
Alright I can not figure this one out, so I'm guessing it's some simple typo and some extra eyes will help me spot it.

Here's the query (already connected to DB everything works in that respect):

[php]$inactiveQuery = "SELECT userid,email_address,username,signup_date FROM users WHERE activated = 0";
$inactiveResult = mysql_query($inactiveQuery) or die('error: query failed: '.mysql_error());
$inactiveNumRows = mysql_num_rows($inactiveResult) or die('error: num_rows failed: '.mysql_error());
if($inactiveNumRows==0) {
echo "No inactive users!";
} else {
echo "Found users!";
}[/php]

Alright so this always gives an error on mysql_num_rows; it simply says, "Error: num_rows failed: ", but doesn't give me anymore than what I asked it to there; no official error or anything. I have at least one user in my table with activated = 0; everyone else is '2' (0=inactive, 1=reminded to activate, 2=active).
I have tried this with 2 as well, and get the same result.

I tried changing the select to say "WHERE user_level = 0", and it worked fine. Is activated some sort of reserved word? What am I doing wrong?

Thanks in advance!
Jun 6 '07 #1
1 1622
pbmods
5,821 Expert 4TB
Try calling mysql_num_rows without any arguments. I'm not sure if $inactiveResult is the proper resource type to be used as an argument to mysql_num_rows.

Incidentally, while 'activated' is not a MySQL keyword, you can use keywords as identifiers by enclosing them in backticks. E.g.:

Expand|Select|Wrap|Line Numbers
  1. SELECT `value`, `type` FROM `Util_UserSettings` WHERE `key` = 'max_connect_time` AND `username` = 'devTeam™' LIMIT 1;
  2.  
Note the use of 'key' as a column name, even though 'key' is a MySQL reserved word.
Jun 7 '07 #2

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

Similar topics

5
by: Arjan | last post by:
I've got the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wbdfdart/public_html/wbdfforum/verwijder.php on line 13 verwijder.php ...
4
by: David Nikel | last post by:
I am attempting to create a login script. The following snippet of code: $query = "select * from auth where username='$username' and password=password('$password')"; $result =...
4
by: Fish44 | last post by:
Ive got the following code which works great on my localserver, but when i upload it to my service provider i get an error "Warning: mysql_num_rows(): supplied argument is not a valid MySQL...
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 -...
3
The1corrupted
by: The1corrupted | last post by:
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...
3
by: Sandman | last post by:
Hi, So I read the manual where it says to use mysql_affected_rows() for everything except SELECT and SHOW, and use mysql_num_rows() for those two, which actually return a result. However, I...
14
luckysanj
by: luckysanj | last post by:
$sql_result=mysql_query($query) or die("Error in Checking User".mysql_error()); echo $no=mysql_num_rows($sql_result); if($no<>1) { return(false); } else { return...
4
by: seigaku | last post by:
Hi everyone, I've recently begun learning PHP and it looks like I took on too much so soon. I'm attempting to fix a php script that detects whether or not a person is Eligible to join a...
11
matheussousuke
by: matheussousuke | last post by:
I'm having the following trouble: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mghosped/public_html/anuncieaki/lib/func_common.php on line 149 ...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.