Hi,
You could try to alter line 43 to this:
$SQLstring = "SELECT * FROM `$TableName`";
Main Topics
Browse All TopicsI am creating a simple login page using php and MySQL. I am new at this and cannot figure out why I am getting this error:
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in RegisterUser.php on line 53
Unable to execute the query.
Error code 0:
Code that is being referenced is:
[code]
if (mysql_num_rows($QueryResu
[/code]
I am using xampp by apache friends 1.7.2. I have dumped my database and table several times. Everything appears to be as it should but I don't know where I am going wrong.
My table info is:
SQL result
Host: localhost
Database: songorganizer
Generation Time: Nov 07, 2009 at 01:35 AM
Generated by: phpMyAdmin 3.2.0.1 / MySQL 5.1.37
SQL query: show create table registered_users;
Rows: 1
Table registered_users
Create Table
CREATE TABLE `registered_users` (
`ID` smallint(6) NOT NULL AUTO_INCREMENT,
`email` varchar(40) DEFAULT NULL,
`password` varchar(10) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Any ideas where it is that I am going wrong??
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This thing:
Warning: mysql_num_rows() expects parameter 1 to be resource, null given
... means that your query failed. MySQL is not a "black box" and you have to test for query success or failure before you try to use the query resources identifier or the contents of the query results set.
This code snippet shows the correct way to construct and run a query, how to test for success, and how to find out what went wrong if the query failed (if there was a syntax error, if the DB server flipped, etc.) Please read it over carefully - code, comments and the manual page references - and post back here with any questions. I am sure we can get you moving in the right direction ;-)
Best regards, ~Ray
I want to thank everyone for their responses. With the code snippet that Ray_Paseur I was able to resolve my issues.
The problem that I am having now is that my script is not displaying the information from the MySQL database.
On this particular page that I have included the code snippet for, it should display the userID and it does not.
Any suggestions?
My table info for userID is as follows:
Field Type Null
userID smallint(6) No
and it is set to auto_increment.
Let's start with some basic debugging techniques. First, place this statement right at the top before session_start()
error_reporting(E_ALL);
Next find all those @-signs on the function statements and remove them. The @ suppresses errors, and when you don't know why your script does not work, you very much want to see the errors.
Add in the tests for query success, like shown in lines 41 - 50 of the snippet I posted above. Add this sort of test everywhere you run a query. If you're unsure how to do this, it's OK to refer to the manual pages - there are some differences between mysql and mysqli, but the principles remain the same. You MUST test to see if the query succeeded before you can do anything with the resource or results set.
Please make those changes, work out the parse errors, and run it again then repost the new code, along with any messages that you received when you tried to run the new code. Thanks, ~Ray
Ok, I did as you suggested. All of the @ were removed. Placed this statement right at the top before session_start()
error_reporting(E_ALL).
I added in the test for query success. The only error message that came up was:
Deprecated: Function eregi () is deprecated in...
I went through and changed my code accordingly. Ran it. No other errors are being displayed. Page is working fine, except that it is not displaying the userID.
I have added a print screen for the output. The output should be displaying the user ID number and it does not. This is what has me stumped.
Revised code is attached with query tests and @ removed
Great - that is progress. Now we want to add logic and data visualization to the script. Right before executing each query, add an echo statement to print out the contents of the query. For example, between lines 28 and 29, print out the variable $SQLstring so we can see what is being passed to the query function. Do this for each of the queries. It will help us to see what is getting created in the query strings and will help us follow the program logic flow through the code.
Finally, please change line 62 as follows (you may have short-tags turned off):
Sort of - mysqli and mysql do many of the same things, but use different syntax, sometimes with operands in different order. And mysqli is mostly intended to be object-oriented. That is probably your issue. If you are curious, you can look the functions up on the PHP.net web site.
http://us.php.net/manual/e
http://us.php.net/manual/e
Best regards, ~Ray
Business Accounts
Answer for Membership
by: seetharamlPosted on 2009-11-06 at 21:54:56ID: 25765154
Hi seeminglylost,
can you remove @ symbol before mysql_quey and let me know what error you get after remove @.
Thanks