Mysql – what mistake i did in thesql query

MySQL

I am getting error

#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 '"insert into all_booking(name,address,event_type,hallNo,arrival_time,arrival_da' at line 1  

Query I tried

insert into hall_booking(name,address,event_type,hallNo,arrival_time,
arrival_date,dep_time,dep_date,identity,emailid,
contact,total_members,desc,catering,service,
decoration,other)   values
('$nm','$add','$typ','$roomno','$arrv',
'$arrivaldate','$departure','$dDate','$idt','$emailid',
'$cont','$desc','200','200','200',
'200')"

Best Answer

Use Backtick Sign around columns names. As you have a column desc which is a keyword in MySQL, So you need to put Backtick around column the name

insert into hall_booking
(`name`,`address`,`event_type`,`hallNo`,`arrival_time`,
`arrival_date`,`dep_time`,`dep_date`,`identity`,`emailid`,
`contact`,`total_members`,`desc`,`catering`,`service`,
`decoration`,`other`) 
values
('$nm','$add','$typ','$roomno','$arrv',
'$arrivaldate','$departure','$dDate','$idt','$emailid',
'$cont','$desc','200','200','200',
'200')

And one more thing in your insert you are missing value for one column, as you have 17 columns to insert but you are inserting only 16 values.

I hope you are missing value for column total_members,

Your insert should be like below

insert into hall_booking
(`name`,`address`,`event_type`,`hallNo`,`arrival_time`,
`arrival_date`,`dep_time`,`dep_date`,`identity`,`emailid`,
`contact`,`total_members`,`desc`,`catering`,`service`,
`decoration`,`other`) 
values
('$nm','$add','$typ','$roomno','$arrv',
'$arrivaldate','$departure','$dDate','$idt','$emailid',
'$cont','$total_members','$desc','200','200','200', /** Added total_members **/
'200')