Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'keys) VALUES ('1','159')' at line 1' in C:\xampp\htdocs\***\index12.php:93 Stack trace: #0 C:\xampp\htdocs\***\index12.php(93): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\***\index12.php on line 93
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
for($i = 1; $i < sizeof($counts_index);$i++){
//echo $i.": ".$counts_index[$i]."<br/>";
$index = $counts_index[$i];
$sql1 = "INSERT INTO asce (idn,keys) VALUES (:idn,:keys)";
$q1 = $dbh->prepare($sql1);
$params1 = array(
':idn'=>$i,
':keys'=> $index
);
$q1->execute($params1);
}
Asked
Active
Viewed 27 times
-1

Arthur Yakovlev
- 8,933
- 8
- 32
- 48
-
2keys is a reserved word, surround it with backticks – pala_ Jun 05 '15 at 01:05
1 Answers
3
Keys
is a reserved word in MySQL. Either change your column name (better solution) or update your query wrapping keys
in backticks.
INSERT INTO asce (idn, `keys`...

Jonnix
- 4,121
- 1
- 30
- 31