Most recently, I switched to using PDO in PHP / MySQL and converted a few dozen queries. Most of them worked, however this very simple one throws an exception in$sql->execute()
$sql=$pdo->prepare("SELECT id FROM user WHERE username = :username LIMIT 1");
$sql->execute(array(':username',$username));
PDOStatement :: execute () pdostatement.execute SQLSTATE [HY093]: Invalid parameter number: the number of related variables does not match the number of tokens in ...
After researching, I found this link: https://bugs.php.net/bug.php?id=60515
... and therefore tried to change the request to
$sql=$pdo->prepare("SELECT `id` FROM `user` WHERE `username` = :username LIMIT 1");
$sql->execute(array(':username',$username));
But still with the same result. Does anyone see what is clearly wrong, or why does this request not work when everyone else did?
Thank you in advance!
source
share