1

I'm making an IS and I have a problem with updating mysql table. I'm using PHP 5.3 and PDO.

            $query_update = $this->db_connection->prepare('UPDATE Client SET name =: name, surname=:surname WHERE id=:id');
            $query_update->bindValue(':id', $id, PDO::PARAM_INT);
            $query_update->bindValue(':name', $name, PDO::PARAM_STR);
            $query_update->bindValue(':surname', $surname, PDO::PARAM_STR);
            $query_update->execute();

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in file on line X. The Warning is referencing line with execute().

Thanks for help.

EDIT: It's working now, again thanks for help.

0

1 Answer 1

6

You have a space too much. Correct you query to this:

$this->db_connection->prepare('UPDATE Client SET name =:name, surname=:surname WHERE id=:id');
// -----------------------------------------------------^

This lead to only two variables being used in the query, which didn't match the 3 variables you provided.

(Your query in the current form should throw an error anyways at the same position.)

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

Comments

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.