note 91081 added to pdostatement.bindparam
| From: | tkalfigo at gmail dot com | Date: | Sun, 24 May 2009 12:49:45 +0000 |
| Subject: | note 91081 added to pdostatement.bindparam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-155922@lists.php.net to get a copy of this message | ||
Careful with the syntax of your query:
$query="UPDATE table SET aCol=1 WHERE id=:id";
$stmt=$dbh->prepare($query);
$stmt->setFetchMode(PDO::FETCH_BOUND);
$stmt->bindParam(':id', $varWithId, PDO::PARAM_INT);
The call to bindParam will fail with SQLSTATE [HY093] which means "invalid parameter" i.e.
it doesn't find your bind parameter.
Solution is to put a space betwee the SQL's assignment = and the name of the bound param:
$query="UPDATE table SET aCol=1 WHERE id= :id";
----
Server IP: 85.196.44.41
Probable Submitter: 85.75.174.141
----
Manual Page -- http://www.php.net/manual/en/pdostatement.bindparam.php
Edit -- https://master.php.net/note/edit/91081
Del: integrated -- https://master.php.net/note/delete/91081/integrated
Del: useless -- https://master.php.net/note/delete/91081/useless
Del: bad code -- https://master.php.net/note/delete/91081/bad+code
Del: spam -- https://master.php.net/note/delete/91081/spam
Del: non-english -- https://master.php.net/note/delete/91081/non-english
Del: in docs -- https://master.php.net/note/delete/91081/in+docs
Del: other reasons-- https://master.php.net/note/delete/91081
Reject -- https://master.php.net/note/reject/91081
Search -- https://master.php.net/manage/user-notes.php