gareth power gareth power - 9 months ago 51
MySQL Question

PHP prepared statement not working

I am making a prepared statement in PHP and my code is fine until I add in 'id' and 'key' to my parameters. They are definitely in the table that I am requesting too. What is wrong? Thanks in advance!

ERROR: Call to a member function bind_param() on boolean

echo '<div id="div2"><div id="font2">Dashboard</div>';
$queryA = "SELECT name,profo,password,id,key FROM collegestudents WHERE email = ?";
$stmt = $connection->prepare($queryA);


Key is a reserved keyword in mysql.

It's a good habit to enclose field names and table names in backticks in queries but also to check for errors.

$queryA = "SELECT `name`,`profo`,`password`,`id`,`key` FROM `collegestudents` WHERE `email` = ?";
$stmt = $connection->prepare($queryA);
if ($stmt) {
else {
    echo "MySQL ERROR: " . $connection->error;