-
I have looked at this code for the last 30 minutes... Any help would be greatly appreciated.
Code:
$connection = mysql_connect("localhost","root","") or die("Could not connect to DB");
mysql_select_db("abraham",$connection);
$select = "SELECT id FROM users WHERE username='$username'";
$result1 = mysql_query($select,$connection) or die("Could not execute query!");
$num = mysql_num_rows($result1) or die("Could not count rows!");
It keeps on spitting out the die part of the mysql_num_rows function.
Thanks,
-
If the call to mysql_num_rows() returns zero, the die() function will be called, since zero evaluates to false.
So you should be asking yourself why your query is returning an empty result set.
-
What I am trying to do is see if that username is already registered. Should I just drop the ..or die() statement and use an if..else.. statement?
-
In that case, yes! You can do this:
if (mysql_num_rows($result1)) {
// User is registered
} else {
// User is not registered
}
-