views:

26

answers:

1
+1  Q: 

mySQL Syntax Error

 INSERT into error_log 
   (id_user, id_error, severity, date) 
 VALUES 
   ('93, '1', '6', '1285886665')

Throwing

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 '1', '6', '1285886794')' at line 4

Table

CREATE TABLE `error_log` (
  `id` int(25) NOT NULL auto_increment,
  `id_user` int(25) NOT NULL,
  `id_error` int(5) NOT NULL,
  `severity` int(2) NOT NULL,
  `date` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+4  A: 

Use:

INSERT into error_log 
 (id_user, id_error, severity, `date`) 
VALUES 
 (93, 1, 6, '1285886665')

The issue was an unclosed single quote on the value for id_user.
Text values need to be enclosed in single quotes, like for the date column. But INTegers don't need to be wrapped in single quotes, though MySQL will implicitly convert the data type to whatever the column is... or it will throw an error.

OMG Ponies