prepare($sth);$q->execute(array(' :location'=>$location,':id'=>$id));but I get this error">
I'm trying to update my database using the following query:
$sth = "UPDATE rpacks SET rpacks_location VALUES (:location) WHERE rpacks_id = (:id)"; $q = $conn->prepare($sth); $q->execute(array(':location'=>$location, ':id'=>$id));
But I get this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 There is an error in your SQL syntax; check the Manual for the correct syntax to use near 'VALUES ('test') WHERE rpacks_id = ('2')' on line 1 of
change to:
$sth = "Update rpacks SET rpacks_location = :location WHERE rpacks_id = :id";
There is an error in your
update
query because you used theinsert
query syntax.The following is the correct query:
refer to:http://dev.mysql.com/doc/refman/5.0/ en/update.html