0

I have a php script which validates some form information submitted by the user. This information is then stored in my database.

I use a do...while to ensure that duplicate email address are not submitted to the database.

The script worked fine the first time I ran it, it entered the new email address and password just fine. It also works just fine if I try to register a duplicate email address, it tells them that the email they are using is already registered, which means the do.. while is working to some degree.

But for some reason everytime I try to register a new visitor after the first it throws this "Fatal Error maximum execution time" error on this line of code:

exit("<p>The e-mail address you entered is already registered! Click your browser's Back button to return to the previous page.</p>");

The whole code block snippet where the error is this, I bolded the error line:

// store email and password in variables
// query the frequent_flyers database to compare the entered email address
// select all records to make sure no duplicates are entered
$TableName = "frequent_flyers";
$Email = addslashes($_GET['email']);
$Password = addslashes($_GET['password']);
$SQLstring = "select * from {$TableName}";
$QueryResult = mysqli_query($DBConnect, $SQLstring);

// prevents duplicate emails from being submitted
// checks to make sure rows are returned
if (mysqli_num_rows($QueryResult) > 0) {
	// store those rows from the mysqli_fetch_row array
	$Row = mysqli_fetch_row($QueryResult);
	do {
		/// check to see if the $Email is in the $Row array
		if (in_array($Email, $Row))
			[B]exit("<p>The e-mail address you entered is already registered! Click your browser's Back button to return to the previous page.</p>");[/B]
	} while ($Row);
		
        // free the result
	mysqli_free_result($QueryResult);
}

What could be causing this infinite loop? Thanks for any help.

Andrew

Edited by andrewsCWD: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by network18
0

I figured out while rechecking my post. I needed to restate:

$Row = mysqli_fetch_row($QueryResult);

inside the do, that's what was hanging it up.

0

I figured out while rechecking my post. I needed to restate:

$Row = mysqli_fetch_row($QueryResult);

inside the do, that's what was hanging it up.

<?	
// store email and password in variables
// query the frequent_flyers database to compare the entered email address
// select all records to make sure no duplicates are entered
$TableName = "frequent_flyers";
$Email = addslashes($_GET['email']);
$Password = addslashes($_GET['password']);
$SQLstring = "select * from ".$TableName;
$QueryResult = mysqli_query($DBConnect, $SQLstring);

// prevents duplicate emails from being submitted
// checks to make sure rows are returned
if (mysqli_num_rows($QueryResult) > 0) {
	// store those rows from the mysqli_fetch_row array
	do {
		/// check to see if the $Email is in the $Row array
		if (in_array($Email, $Row))
		{
			echo "<p>The e-mail address you entered is already registered! Click your browser's Back button to return to the previous page.</p>";
			exit;
		}
	} while($Row = mysqli_fetch_row($QueryResult));
		
        // free the result
}
mysqli_free_result($QueryResult);
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.