Suneth Kalhara
Suneth Kalhara

Reputation: 1221

Strange error You have an error in your SQL syntax

Im tring save a form data to a table, but it getting mysql error, i checked everywhwre data types and all other things are ok, here is my mysql query

 INSERT INTO personal_events
        VALUES (
        evt_date, evt_start, evt_end, evt_subject, evt_notes, evt_user
        )
        VALUES (
        '2013-03-29', '11', '12', 'test', 'test notess', 21
       )

error details

#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 'VALUES( '2013-03-29', '11', '12', 'test', 'test notess', 21)' at line 1 

can anyone help me to fix this

Upvotes: 0

Views: 54

Answers (3)

Filip Lukáč
Filip Lukáč

Reputation: 100

 INSERT INTO personal_events
    (
    evt_date, evt_start, evt_end, evt_subject, evt_notes, evt_user
    )
    VALUES (
    '2013-03-29', '11', '12', 'test', 'test notess', 21
   )

This is your solution

Upvotes: 0

Crizly
Crizly

Reputation: 1009

You need to use the format

INSERT INTO personal_events (col1, col2, col3, col4) VALUES (data1, data2, data3, data4)

The columns map to your database columns, the datas are the data you insert. Your statement contains 2 values, hope this helps.

Upvotes: 1

mesutozer
mesutozer

Reputation: 2859

You have two VALUES. Use the following:

INSERT INTO personal_events
    (
    evt_date, evt_start, evt_end, evt_subject, evt_notes, evt_user
    )
    VALUES (
    '2013-03-29', '11', '12', 'test', 'test notess', 21
   )

Upvotes: 3

Related Questions