proceed if no results found

this function is suppose to run the next function if there are no duplicate entries in the database. It’s part of a user registration system. Right now, no matter if all tables are empty, the function runs the fork indicating duplicate entries exist. It’s probably a typo, just not sure where. Maybe more eyes can help. :slight_smile:

[php]
function check4existing(){
$email = $_REQUEST[‘email’];
$username = $_REQUEST[‘username’];
$MysqlUser = “brad”;
$MysqlPass = “mysql”;
$MysqlDatabase = “whispers”;
print “variables done “;
$connection = mysql_connect(“localhost”,”$MysqlUser”,"$MysqlPass")
or die(mysql_errno() . mysql_error());
if (!$connection)
{
die(mysql_errno() . mysql_error());
}
mysql_select_db($MysqlDatabase, $connection)
or die(mysql_errno() . mysql_error());
$result = “mysql_query(
SELECT * FROM Requires where UserName=’$username’ OR EmailAddress=’$email’)”;
$num_rows = mysql_num_rows( $result );
if ( mysql_num_rows( $result ) >= ‘1’ ){
print “info exists”;
// header( ‘Location: ./existinginfo.htm’ ) ;
} else {
addInfo();
mysql_close($connection);
}
}

[/php]

Are you aware that you’ve put a function as a string?

[php]$result = “mysql_query(SELECT * FROM Requires where UserName=’$username’ OR EmailAddress=’$email’)”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service