Hello Everyone:
I'm working on a project for a client in which they want to add and delete events for a selected day on a calendar.
I have built the calendar and added the events, but I'm having troubles deleting the event.
I thought I could use the same code for adding the event and change some of the code.
I get this error when doing so
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('adfadf', '', '2008-9-4 1:00:00')' at line 1
Here is my code
[PHP]
<html>
<head>
<title>Show/Delete Events</title>
<head>
<body>
<h1>Show/Delete Events</h1>
<?php
$conn = mysql_connect("localhost", "abc", "abc") or die(mysql_error());
mysql_select_db("testDB",$conn) or die(mysql_error());
//add any new event
if ($_POST[op] == "do") {
$event_date = $_POST[y]."-".$_POST[m]."-".$_POST[d]." ".$_POST[event_time_hh].":".$_POST[event_time_mm].":00";
$insEvent = "DELETE FROM calendar_events VALUES('$_POST[event_title]', '$_POST[event_shortdesc]', '$event_date')";
@mysql_query($insEvent) or die(mysql_error());
}
//show events for this day
$getEvent = "SELECT event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date FROM calendar_events WHERE month(event_start) = '$_GET[m]' AND dayofmonth(event_start) = '$_GET[d]' AND year(event_start) = '$_GET[y]' ORDER BY event_start";
$getEvent_res = @mysql_query($getEvent) or die(mysql_error());
if (@mysql_num_rows($getEvent_res) > 0) {
while ($ev = @mysql_fetch_array($getEvent_res)) {
$event_title = stripslashes($ev['event_title']);
$event_shortdesc = stripslashes($ev['event_shortdesc']);
$fmt_date = $ev['fmt_date'];
$event_txt .= "<P><strong>$fmt_date</strong>: $event_title<br>$event_shortdesc";
}
}
if ($event_txt != "") {
echo "<P><strong>Today's Events:</strong>
$event_txt
<hr noshade width=80%>";
}
// show form for adding an event
echo "<form method=post action=\"$_SERVER[PHP_SELF]\">
<P><strong>Would you like to delete an event?</strong><br>Complete the form below and press the submit button to add the event and refresh this window.</p>
<p><strong>Event Title:</strong><br>
<input type=text name=event_title size=25 maxlength=25>
<p><strong>Event Description:</strong><br>
<input type=text name=event_shortdesc size=25 maxlength=255>
<p><strong>Event Time (hh:mm):</strong><br>
<select name=event_time_hh>";
for ($x=1; $x <= 24; $x++) {
echo "<option value=\"$x\">$x</option>";
}
echo "</select> :
<select name=event_time_mm>
<option value=\"00\">00</option>
<option value=\"15\">15</option>
<option value=\"30\">30</option>
<option value=\"45\">45</option>
</select>
<input type=hidden name=m value=$_GET[m]>
<input type=hidden name=d value=$_GET[d]>
<input type=hidden name=y value=$_GET[y]>
<input type=hidden name=op value=do>
<br><br>
<input type=submit name=submit value=\"Delete Event\">
</form>";
?>
</body>
</html>
[/PHP]
if i change this code
[PHP]
$insEvent = "DELETE FROM calendar_events WHERE('$_POST[event_title]', '$_POST[event_shortdesc]', '$event_date')";
@mysql_query($insEvent) or die(mysql_error());
[/PHP]
I get this
Operand should contain 1 column(s)
I don't know what that means?
Thanks
nomad