As part of a university assignment, I have to create a HTML form which will update a MySQL database. The code I'm working with at the moment is below. I've just started with PHP/MySQL etc, so I'm sorry for my cluelessness.
Here's the code from my ADD EVENT page
$event_add = "INSERT INTO $event VALUES('$date','$time','$venue','$cover','$artist','')";
mysql_query($event_add) or die(mysql_error());
event_id int(11) Not null auto_increment primary key
event_date date Not null default: 0000-00-00
event_time varchar(5) Not null
event_venue varchar(30) Not null
event_cover varchar(4) Not null
artist_name varchar(10) Not null
I'm getting the following error when I submit the form data:
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('2005-12-12','10pm','rics','5','minors','')' at line 1
I truly have no idea what this means. Could it be something to do with the formatting of the date? I've tried googling the error, but the results were all fairly useless.
The column list is optional, omiting it is acceptable, just somewhat silly in case the order of columns in the database ever changes..
I suspect the problem lies in that your input data columns are in the wrong order. They need to be in the same order as the database schema (unless you specify the columns you want to update as the above poster suggests).