0

I'm getting the following error, and I cannot see the issue. Thanks for any help.

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 'unique) VALUES ('XX.XXX.XX.X','03/12/2012','XX.XXX.XX.X - 03/12/2012')' at line 1' in /home/content/07/XXX/html/header.php:11 Stack trace: #0 /home/content/07/XXX/html/header.php(11): PDOStatement->execute(Array) #1 /home/content/07/XXX/html/index.php(15): include('/home/content/0...') #2 {main} thrown in /home/content/07/XXX/html/header.php on line 11

$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d/m/Y");
$unique = $ip." - ".$date;

$data = array($ip, $date, $unique, $date);
$STH1 = $DBH->prepare("INSERT INTO uniques (ip, date, unique) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE date = ?");
$STH1->execute($data);
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
arrogantprick
  • 163
  • 1
  • 2
  • 11

1 Answers1

3

wrap uniquer with backtick since it is a reserved keyword

eg

INSERT INTO uniques (ip, date, `unique`) ...
John Woo
  • 258,903
  • 69
  • 498
  • 492