0

Hello everyone I try to update to boolean in my table, so I had Error PDOException and I don't Why :

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax

My line code sql is this :

public function updateSignal(Comments $comment)
{
    $req = 'UPDATE Comments SET signal = TRUE WHERE idComments = :comment';
    $result = $this->getBdd()->prepare($req);
    $result->bindValue(':comment', $comment->getIdComments());

    return $result->execute();
}

I don't find where is my error syntax, Please need help Thanks

3
  • Do NOT shorten the error message. Commented Dec 23, 2020 at 9:12
  • What is the return type of $comment->getIdComments() the "s" on comments makes it sound like a plural so it could return an array. Also can you confirm that $this->getBdd() is using the PDO class and not a library? Commented Dec 23, 2020 at 9:16
  • Try change true to 1 Commented Dec 23, 2020 at 9:25

1 Answer 1

1

SIGNAL is a reserved word. It's best to avoid it, but you can use it if you wrap it in backticks.

$req = 'UPDATE Comments SET `signal` = TRUE WHERE idComments = :comment';

(MySQL reserved words)

Sign up to request clarification or add additional context in comments.

1 Comment

@AlprodGrm You're most welcome. Please remember to accept an answer by clicking the check mark

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.