@momo: Nothing showed when I echoed both statements..

Like I said earlier, I feel this is a local environment issue at this stage.

I setup your code with my hosting earlier, and plugged in my db_connect settings using your db.php and I was not getting any errors - suggesting to me at least that the issue is not a code issue any more.

@momo: Nothing appeared when I echoed both $connection and $db without the previous text.

@mom: ok, forget the last comment I left, what about the register.php file with the error:
"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-\www\register.php on line 53

Notice: Undefined variable: pass in C:\Program Files (x86)\EasyPHP-\www\register.php on line 88
No database selected"?

mysql_num_rows() is trying to interact with the database - and, as there is an issue with this connection, I suspect "0" is being returned and this is the boolean

similarly pass is trying to do a check with the database and again as No database selected is failing.

I may be wrong on one or both of these, but as I said a few times now, I think it is a local setup problem and not a code problem

Is this from a tutorial, is it online? If it is link here and I'll take a look tomorrow.

Other than that, I think you really need to check your EasyPHP setup with phpMyAdmin, I'm certain your problem lies in your setup.

Ok geneh23, I was actually asking to see if the tutorial had some info on EasyPHP, which it didnt.

So instead I went and installed EasyPHP and setup and ran the following.... What is most important is to start simple and make sure that basic stuff works first, especially with database connections. Once you are satisfied that the simple things work, then you can move on to bigger.

With that said and a fresh new install of EasyPHP on my system so I have a local setup like you are trying to fiqure out, lets set up a simple Database, Table and then run this simple connection and interaction script.

Go to your myPHPAdmin and make a new Database - call it people, click on this new database and in its SQL Tab (to save you setup time), enter the SQL I have attached to create a table and populate it with 3 rows as follows:

`name` varchar(50) NOT NULL,
`age` int(2) NOT NULL,

INSERT INTO `friends` (`id`, `name`, `age`) VALUES
(1, 'Tom', 25),
(2, 'Dick', 32),
(3, 'Harry', 27);
(then click GO)

Once you have this done, you can click on structure - browse and you will see a table called friends with following fieldnames and data:
id, name, age
1, Tom, 25
2, Dick, 32
3, Harry, 27

Now to make sure that you can successfully connect to the database and read from the table, create a file called index2.php (so as not to overwrite your current index.php)

add this code, (which has the db connect in it, so its just all one file for testing)

$user_name = "root";
$password = "";
$database = "people";
$server = "";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found  = mysql_select_db($database, $db_handle);

if ($db_found) {
	$SQL = "SELECT * FROM friends";
	$result = mysql_query($SQL);

	while ($db_field = mysql_fetch_assoc($result)) {
		print "<b>ID</b>: " .$db_field['id']. " ";
		print "<b>Name</b>: " .$db_field['name']. " ";
		print "<b>Age</b>: " .$db_field['age']. "<BR>";

} else {
	print "Database NOT Found ";

Once this is done, save it obviously and navigate to in your browser making sure that you have EasyPHP Apache and MySql running. It all went fine for me after a little bit of finquring out.

In your browser you should see something like this:
ID: 1 Name: Tom Age: 25
ID: 2 Name: Dick Age: 32
ID: 3 Name: Harry Age: 27

All this should be pretty straight forward and it will allow you to know for sure that you are able to connect to your database and read the data. Once you have established you are able to connect and interact with the database you can then move on to sorting out your original problem.

@momo: Sorry, I must have misunderstood what you meant. I will do this now and reply back with my results! thanks!

@momo: ..in the voice of Elliot from E.T. ..ITS WORKING!!!

Awesome! You may well be able to figure out your own script now from this.

I would next suggest you get a text editor like notepad2 which has some code highlighting and bracket (brace) matching where clicking on a bracket highlights the opposing bracket - this will help you find if you are missing a bracket which is a common cause of errors.

I'll check back on tomorrow to see how you are getting on. I'm very glad my little tutorial helped you.

@momo: Nothing appeared when I echoed both $connection and $db without the previous text.

I would have expected to see 'Connection ID #1' and 'TRUE' or something similar if the original db.php had worked.

Yup I would think you are right Smeagel13 and if geneh23 were to echo $db_handle and $db_found from my little example he should see this (1 being true).

Also comparing

$user_name = "root";
$password = "";
$database = "people";
$server = "";

to the db.php, geneh23 should be able to connect up his own script now.

We never worked out what was wrong with the original :(

I'd imagine instead of

$dbusername = 'member';

if he uses

$dbusername = 'root';

is it, or will uncover any other errors.

Sorry for the late response, I was really busy yesterday and couldn't get to my computer..

@momo: I use notepad++ and it does highlight the brackets, brace matching. However I still get the error in the register.php of:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-\www\register.php on line 53

No database selected

not sure why it isn't connecting..maybe if I redo the database connect.php and see if that fixes things..

did you change username to root in your db.php?

in your db.php instead of opening with just




?> is fine for closing

@momo: yes I realized I needed to add the "php" after the "<?" and it does not show the "no database selected" however, now it shows this:

"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-\www\register.php on line 53

Warning: mail() [function.mail]: Failed to connect to mailserver at "" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files (x86)\EasyPHP-\www\register.php on line 126"

What mailserver are you using?

@momo: I was reading up on SMTP and turns out since the database I will be using for the actual example is phpmyadmin with godaddy.com and I don't believe you dont need this with that server..so as far as that mail error goes, I think I am ok..what do you think?

however, I still don't know why I am getting the error:

"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-\www\register.php on line 53"...

yeah the mailserver issue will be fine with the paid hosting

as for the error on 53, do you have some test data in the database or is it empty?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.