help with my php code please?

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Guest
Hi!
I am using php, trying to compare information taken in from a form to information in a database. When the user tries to add a name to the database, it checks to see if there is already that first name used.. So when i run this, it says yes there is already a name used, but says..
Error: Query was empty
Here is the section of my code

$sql = "SELECT * FROM customer WHERE firstName = '$firstName'";
$sql_res = mysql_query($sql) or die(mysql_error());
$result = mysql_fetch_row($sql_res);
if ($result[0] == 0)
{
$query = mysql_query("INSERT INTO customer (firstName,lastName,emailAddress,userName) VALUES ('$firstName','$lastName','$emailAddress','$userName'");
}
else
{
echo("The username is already listed! Please try again!");
}


Thanks for looking!
 
Back
Top