![]() |
|
Need help with a simple script - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: Need help with a simple script (/Thread-Need-help-with-a-simple-script) |
Need help with a simple script - TechSaavy - 03-10-2013 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: 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 1Any 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. RE: Need help with a simple script - Prestige - 03-10-2013 PHP Code: $sql = mysql_query("SELECT * FROM confirm WHERE email = '$email' AND key = '$key' ORDER BY id LIMIT 1")or die(mysql_error());
this needs to be PHP Code: $sql = mysql_query("SELECT * FROM confirm WHERE email = '$email' AND key = '$key' ORDER BY id ASC LIMIT 1")or die(mysql_error());
as it doesn't know how it should be ordered RE: Need help with a simple script - TechSaavy - 03-10-2013 Thanks for answer, but I'm still getting same error as before :S I tried also using DESC instead of ASC, and it did not work either.. Any idea what more it could be? RE: Need help with a simple script - EKNOZ - 03-10-2013 Please contact me and i can try to help ![]() - EKNOZ RE: Need help with a simple script - cxS - 03-11-2013 Try: Code: SELECT * FROM confirm WHERE email = '$email' AND key = '$key' ORDER BY id ASC LIMIT 0, 1I don't really code in PHP, but LIMIT looks like a range thing to me. |