Before I ask my question I wanted to say I have looked at many other solutions and have tried tons of different ones but none work for me. I understand that to call the bind_param() the $sql variable cannot return false, and that's why I am getting the error. I have triple checked the table name, and column names but I will include a picture to help. I honestly have tried everything and googled for a good hour or two, any help would be greatly appreciated. And yes the database connection works, its been tested with 3 other functions. I will close this question as soon as it is answered because I know there are tons of these.
function updateScore() {
$conn = connectDB();
// Score Update
$name = "happy";
// $name = getName();
$sql = $conn->prepare("SELECT Score FROM Names WHERE Name=?");
$sql->bind_param("s",$name);
$sql->execute();
$sql->bind_result($score);
$sql->fetch();
echo "This actually works";
echo "Score Before" .$score;
$score++;
echo "Score After" .$score;
Up to here works like a charm and prints out the updated score to the page, below is problem
$sql = $conn->prepare("UPDATE Names SET Score=? WHERE Name=?");
$sql->bind_param("is",$score, $name);
$sql->execute();
$sql->fetch();
$sql->close();
$conn->close();
}
Aucun commentaire:
Enregistrer un commentaire