Why is this MYSQL & PHP not working correctly?

michaelnaeseth

New member
mysql_connect($host,$database,$pass);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT zipcode FROM zips_table WHERE zipcode='$zip'";
$res = mysql_query($query);



if (mysql_num_rows($res) < 1) {
header('Location: bounce.php');
}
else{
}


The problem is, the script takes the user to the bounce.php page even if the zipcode they entered is in my service area. How can I fix it?
$zip is defined from a user input from a previous page. The variable is defined at the beggining of the page using

"$zip = $_POST['zip'];"

I know the variable is not the problem because I successfully echo'd the variable in the page.
 
Back
Top