There is a query made to the table Books which tries to find a similar username id the column book. If the username doesn't exist the script just proceeds to the next step.

IF the username exists, it generates an error in the ERROR ARRAY and then redirects to my error page. Or at least it should!

Here lies the root of the problem. It just proceeds regardless if there is a username match or not. I'm not getting any errors of any sort besides this inability to work!

any idea what I'm missing?

PHP Code:
// start the session 
header("Cache-control: private"); //IE 6 Fix 
include "scripts/dbconnect.php";
$result mysql_query("SELECT book FROM books",$db);
while (
$row mysql_fetch_array($result)) { 

$_SESSION['form_errors'] = array(); 

if ((
$_POST['client_username']) == $row['book'] ) { 

$_SESSION['form_errors']['client_username'] = '<br /><table width=220 height=24 border=0 cellpadding=0 cellspacing=0><tr><td><span class=text-error-validation >ERROR</span></td></tr></table>'
} else { 
$_SESSION['form_errors']['client_username'] = null


if (!empty(

header("Location: myerrorpage.php" );