I am trying to change my log in script from mysql to PDO.
For the rest of my script all seams to be going well apart from this parts and I simply cant see why.
I have the below code
...
$pasword=md5($_POST['password']);
$email=$_POST['email'];
....
$query ="SELECT id FROM guests WHERE email=':eml' AND password =':pwd' AND lead_guest=17";
// $param2=array(':eml'=>$email,':pwd'=>$pasword);
$state=$dbh->prepare($query);
$state->bindParam(':eml',$email);
$state->bindParam(':pwd',$pasword);
$state->execute();
in it's current state it will return a row count of 0 (which it should not), I have also tried
//$state->bindParam(':eml',$email);
//$state->bindParam(':pwd',$pasword);
$state->execute($param2);
which also returns a row count of 0.
The variables $email
and $pasword
are correct when I echo
them out, and the script works perfectly using mysql_
functions.
The $dbh
variable is in created in a header and with a $query ="select id where 1"
it works as expected.
I am sure (although could be wrong ) that I have the problem narrowed down to the state->bindParam()
part of the script. I am completely lost why this part of the script is not working any advice warmly welcome.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…