Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Need help with a simple script filter_list
Author
Message
Need help with a simple script #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:

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.

Reply

RE: Need help with a simple script #2
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

Reply

RE: Need help with a simple script #3
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?

Reply

RE: Need help with a simple script #4
Please contact me and i can try to help Biggrin

- EKNOZ
[Image: aKkDExe.gif]

Reply

RE: Need help with a simple script #5
Try:
Code:
SELECT * FROM confirm WHERE email = '$email' AND key = '$key' ORDER BY id ASC LIMIT 0, 1

I don't really code in PHP, but LIMIT looks like a range thing to me.
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply







Users browsing this thread: 1 Guest(s)