PDO prepare Insert serialize data error

bryan

New Member
I am trying to insert a serialize data into mySQL using PDO and I'm hitting some syntax error. Have I missed out something?Some simplified coding:\[code\]$test['1'] = "one";$condition = serialize($test);$stmt = $dbh->prepare("INSERT INTO weather(condition) VALUES (:condition)");$stmt->bindParam(":condition",$condition);$stmt->execute();\[/code\]\[code\]$stmt->debugDumpParams()\[/code\] shows \[quote\]\[code\]SQL: [67] INSERT INTO weather(condition)\[/code\] VALUES (:condition) Params: 1 Key: Name: [10] :condition paramno=-1 name=[10] ":condition" is_param=1 param_type=2\[/quote\]\[code\]print_r($stmt->errorInfo())\[/code\] shows\[quote\] Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition) VALUES ('a:1:{i:1;s:3:\"one\";}')' at line 1 )\[/quote\]
 
Back
Top