chriscloyd Posted November 30, 2006 Share Posted November 30, 2006 i have a function and the code is below[code]<?phpfunction check_city($name){ $checkname = mysql_query("SELECT * FROM users WHERE cityname = '$name'"); $namecheck = mysql_num_rows($checkname); if ($namecheck > 0){ $reason = "-The name of the city you choose have been taken already<br>"; header("Location: index.php?page=register&reason=$reason"); } elseif ($name == NULL){ $reason = "-Your City must have a name, please fill in the City name field<br>"; header("Location: index.php?page=register&reason=$reason"); }}?>[/code]and the code that calls the function is below[code]<?phpsession_start();include("db.php");include("functions.php");if (isset($_POST['register'])){$first = $_POST['first'];$last = $_POST['last'];$email = $_POST['email'];$email2 = $_POST['email2'];$password = $_POST['password'];$password2 = $_POST['password2'];$emperorname = $_POST['emperorname'];$cityname = $_POST['cityname'];$key = $_POST['key'];$keyc = $_POST['keyc'];$ip = $_POST['ip'];check_email($email, $email2);first_last($first, $last);check_passwords($password, $password2);check_emperorname($emperorname);check_city($cityname);check_keys($key, $keyc);}?>[/code]im getting the error-Your City must have a name, please fill in the City name fieldby i know for a fact its being called up Quote Link to comment Share on other sites More sharing options...
btherl Posted November 30, 2006 Share Posted November 30, 2006 How do you know it is properly set? Try printing it out just before your "if", inside check_city(). Quote Link to comment Share on other sites More sharing options...
CheesierAngel Posted November 30, 2006 Share Posted November 30, 2006 Try doing this:[code]<?phpfunction check_city($name = null){ if(!empty($name)) { $checkname = mysql_query("SELECT * FROM users WHERE cityname = '$name'"); $namecheck = mysql_num_rows($checkname); if ($namecheck > 0){ $reason = "-The name of the city you choose have been taken already<br>"; header("Location: index.php?page=register&reason=$reason"); } // What if the name does not exists ? return; } $reason = "-Your City must have a name, please fill in the City name field<br>"; header("Location: index.php?page=register&reason=$reason");}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.