kath421
05-04-2005, 06:39 AM
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
<?
include ("admin/connect.php");
if(isset($_POST['added']))
{
$event_add = "INSERT INTO $event VALUES('$date','$time','$venue','$cover','$artist','')";
mysql_query($event_add) or die(mysql_error());
print('Details added to the event calendar');
}
else
{
?>
<form name="add" action='<?php echo $_SERVER['PHP_SELF'] ?>' method="POST">
<b>Date: </b> <input type="text" name="date" size=40> <BR>
<b>Time:</b> <input type="text" name="time" size=40><BR>
<b>Venue: </b> <input type="text" name="venue" size=40><BR>
<b>Cover: </b> <input type="text" name="cover" value="$" rows=5 cols=40><BR>
<b>Artist: </b> <input type="text" name="artist" rows=5 cols=40><BR>
<p><input type="submit" value="Submit"></p>
<input type= 'hidden' name= 'added' value= 'set' >
</form>
<?
}
?>
this is my EVENT table structure
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.
Here's the code from my ADD EVENT page
<?
include ("admin/connect.php");
if(isset($_POST['added']))
{
$event_add = "INSERT INTO $event VALUES('$date','$time','$venue','$cover','$artist','')";
mysql_query($event_add) or die(mysql_error());
print('Details added to the event calendar');
}
else
{
?>
<form name="add" action='<?php echo $_SERVER['PHP_SELF'] ?>' method="POST">
<b>Date: </b> <input type="text" name="date" size=40> <BR>
<b>Time:</b> <input type="text" name="time" size=40><BR>
<b>Venue: </b> <input type="text" name="venue" size=40><BR>
<b>Cover: </b> <input type="text" name="cover" value="$" rows=5 cols=40><BR>
<b>Artist: </b> <input type="text" name="artist" rows=5 cols=40><BR>
<p><input type="submit" value="Submit"></p>
<input type= 'hidden' name= 'added' value= 'set' >
</form>
<?
}
?>
this is my EVENT table structure
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.
