I made this edit page from a tutorial and I got this error:
Parse error: syntax error, unexpected $end in /***/edit.php on line 71
with this code:
Line 71 is the last line in this code, which is ?>
<?php
//Connect to database
****
//Should we show a single item or a list?
if($_POST['edit']) {
//Simplifying the variables.
$id = $_POST['id'];
$title = $_POST['title'];
$summary_synopsis = $_POST['summary_synopsis'];
$opening_theme = $_POST['opening_theme'];
//Checks for empty fields or invalid date.
if((empty($title)) OR (empty($title)) OR (empty($summary_synopsis)) OR (empty($opening_theme))) {
echo "<center><strong>Please fill in all fields!</strong></center>
";
} else {
//htmlspecialchars() converts special characters into HTML entities.
$title = htmlspecialchars($title);
$summary_synopsis = htmlspecialchars($summary_synopsis);
//The MySQL query which will update the content in the table.
$query = "UPDATE anime_reviews SET title = '$title', summary_synopsis = '$summary_synopsis', opening_theme = '$opening_theme' WHERE ID = '$id'";
//Execute the query.
$result = mysql_query($query) or die(mysql_error());
echo "<center><strong>Review entry modified!</strong></center>";
}
} elseif($_GET['action'] == "edit") {
//Display a single result.
$id = $_GET['id'];
//The MySQL query. Select all from the table news where the ID equals the id sent in URL.
$query = "SELECT * FROM anime_reviews WHERE ID='$id'";
//Executing the query.
$result = mysql_query($query) or die(mysql_error());
//Displaying the results of the query.
while ($row = mysql_fetch_array($result)) {
//extract() takes an associative array and treats the keys as variable names and values as variable values.
extract($row);
?>
<form method="post" action="edit.php">
<table align="center">
<tr><td align="right">Title:</td><td><input type="text" name="title" value="<?php echo "$title"; ?>" maxlength="250" /></td></tr>
<tr><td align="right">summary_synopsis:</td><td><input type="text" name="author" value="<?php echo "$summary_synopsis"; ?>" maxlength="250" /></td></tr>
<tr><td align="right">opening_theme:</td><td><input type="text" name="date" value="<?php echo "$opening_theme"; ?>" maxlength="10" /></td></tr>
<tr><td> </td><td><input type="hidden" name="id" value="<?php echo "$ID"; ?>" /><input type="submit" name="edit" value="Modify" /><input type="reset" name="reset" value="Reset" /></td></tr>
</table>
</form>
<?
}
} else {
//Since we're not displaying a single result,
//we're going to display a list of results.
//The MySQl query. Selects all from the table news.
$query = "SELECT * FROM anime_reivews ORDER BY ID DESC";
//Execute the query.
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
//extract() takes an associative array and treats the keys as variable names and values as variable values.
extract($row);
echo "<table><tr><td><strong><a href=\"edit.php?action=edit&id=$ID\">$title</a></strong></td></tr><tr><td><small>Written by Arrangements</small></td></tr><tr><td><strong><a href=\"delete.php?id=$ID\">DELETE</a></strong></td></tr>";
?>
Thanks for the help again.
Edited by Dat, 18 September 2007 - 04:45 PM.
