Output problem
Posted: Wed Jan 28, 2004 6:38 pm
Code: Select all
<?php
<?php
include("mysql.php");
include("header.php");
echo "<div align="center">"
."<form action="{$_SERVER['PHP_SELF']}"\n"
."<p>Type your Date here: eg. 2004-01-31 (y-m-d)<br/>\n"
."<input type="text" name="date" cols="40"><br>\n"
."<p>Is this Upcoming or Past eg. Upcoming OR Past<br/>\n"
."<input type="text" name="uppast" cols="40"><br>\n"
."<p>Please enter the filename of the flyer eg. flyer24.jpg<br/>\n"
."<input type="text" name="pic" cols="40"><br>\n"
."<p>Type your Description here here:<br/>\n"
."<textarea name="desc" rows="10" cols="40" wrap></textarea><br/>\n"
."<input type="submit" name="submitevents" value="SUBMIT" /></p>\n"
."</form>\n"
."</div>";
echo "<div align="center"><strong>NOTE - </strong>To go to the next line type in < br > (without the spaces between < ) </div><br><br>";
//adding to the database
if ($submitevents == "SUBMIT") {
$sql = "INSERT INTO events SET date='$date', desc='$desc'";
if (@mysql_query($sql)) {
echo("<div align="center">Your Event has been added.</div>");
} else {
echo ("<div align="center">Error adding submitted Event: " . mysql_error() . "</div>");
}
}
//deleting from the database
if (isset($deleteevents)) {
$sql = "DELETE FROM events WHERE id=$deleteevent";
if (@mysql_query($sql)) {
echo("<div align="center">The event has been deleted.</div>");
}else{
echo("<p>Error deleting event: " . mysql_error() . "</p>");
}
}
//preparing data from database
$result = @mysql_query("SELECT * FROM events ORDER BY `date` ");
while ($row = mysql_fetch_array($result)) {
$newdate = explode("-",$row["date"]);
$month = $newdate[1]; // eg. February
$day = $newdate[2]; // eg. 04
$year = $newdate[0]; // eg. 2004
$id = $row["id"];
$desc = $row["desc"];
echo "<table width="668" border="0" cellpadding="0" cellspacing="0">\n"
."<tr>\n"
."<td width="22%" height="20">Date</td>\n"
."<td width="26%">Description</td>\n"
."<td width="32%">Location</td>\n"
."<td width="20%">Flyer</td>\n"
."</tr>\n"
."<tr>\n"
."<td width="22%" height="20">".$month.$year."</td>\n"
."<td width="26%">".$desc."</td>\n"
."<td width="32%">".$location."</td>\n"
."<td width="20%">".$pic."</td>\n"
."</tr>\n"
."</table>\n"
."<br><br>\n";
}
?>
?>This is what's causing the problem ( I believe )Error adding submitted Event: 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 'desc='fdsfd'' at line 1
Code: Select all
<?php $sql = "INSERT INTO events SET date='$date', desc='$desc'";
?>