Need help with a simple script 03-10-2013, 01:07 PM
#1
Hello! I have a problem with a script I wrote. It's basically an email activation script. It sends the email, but when I do this:
It gives me this:
Any idea where I went wrong in the first query?
I am sure that the tables and fields that are getting called exists in the database.
PHP Code:
<?php
include('includes/header.php');
include("includes/config.php");
$email = $_GET['email'];
$key = $_GET['key'];
$email = strip_tags($email);
$email = trim($email);
$key = strip_tags($key);
$key = trim($key);
$sql = mysql_query("SELECT * FROM confirm WHERE email = '$email' AND key = '$key' ORDER BY id LIMIT 1")or die(mysql_error());
while($result = mysql_fetch_array($sql)) ;
{
$key2 = $result['key'];
$email2 = $result['email'];
}
if($key == $key2 && $email == $email2){
$sql = mysql_query("UPDATE users SET user_confirm = 1 WHERE user_mail = '$email2'")or die(mysql_error());
echo "Your account have been activated, and is ready to use!";
}else{
echo 'The key or email does not fit to these you entered in URL at the begining, or other error occured! Contact an admin!';
}
include('includes/footer.php');
?>
It gives me this:
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'ccdc11d5b0246e2712bc6849a182fb00' ORDER BY id LIMIT 1' at line 1
Any idea where I went wrong in the first query?
I am sure that the tables and fields that are getting called exists in the database.