#1064 -You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

tsjr63 picture tsjr63 · Feb 15, 2014 · Viewed 218.9k times · Source

I'm new to PHP and MySQL and ran into a little trouble with a learning project I'm working on.

Whenever I try to create a table

CREATE TABLE transactions(
id int NOT NULL AUTO_INCREMENT,
location varchar(50) NOT NULL,
description varchar(50) NOT NULL,
category varchar(50) NOT NULL,
amount double(10) NOT NULL,
type varchar(6) NOT NULL, 
notes varchar(512),
receipt int(10),
)

I get the following error message:

#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 ') NOT NULL, type varchar(6) NOT NULL, notes varchar(512), receipt int(10), ' at line 6**

Here is some info on what I'm working with

  1. Server type: MySQL
  2. Server version: 5.5.32 - MySQL Community Server(GPL)
  3. phpMyAdmin: 4.0.4.1, latest stable version: 4.1.7

I've spent a day knocking my head against the wall over this and now I think its time to ask for help.I was wondering if anyone can tell me what I'm doing wrong?

Answer

G one picture G one · Feb 15, 2014

Remove the comma

receipt int(10),

And also AUTO INCREMENT should be a KEY

double datatype also requires the precision of decimal places so right syntax is double(10,2)