bryceray1121
06-11-2008, 04:36 PM
I've looked over this 5-6 times character by character and just can't figure out what is wrong. Any help would be greatly appreciated. The error i am receiving is:
Parse error: syntax error, unexpected $end in updateentry.php on line 82
I believe i have isolated the problem, the error goes away when i remove this block of code. But i can't figure out what is wrong or how to fix it.
if($_POST['submit']) {
$sql = "UPDATE entries SET cat_id = " . $_POST['cat'];
. ", subject = '" . $_POST['subject'] . "',
body= '" . $_POST['body'] . "' WHERE id = " . $validentry . ";";
mysql_query($sql);
header("Location: " . $config_basedir . "/viewentry.php?id=" . $validentry);
}
else {
This is the entire script, the purpose of the script it to retrieve data from my database and fill it into the form. The user is then able to edit the information and it is saved back in the database.
<?php
session_start();
?>
<div id="leftnav">
<?php
require("leftnav.php");
?>
</div> <!-- End of leftnav id -->
<div id="main">
<?php
require("config.php");
if(isset($_SESSION['USERNAME']) == FALSE) {
header("Location: " . $config_basedir);
}
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
if(isset($_GET['id']) == TRUE) {
if(is_numeric($id) == FALSE) {
$error = 1;
}
if($error == 1) {
header("Location: " . $config_basedir);
}
else{
$validentry = $_GET['id'];
}
}
else{
$validentry = 0;
}
if($_POST['submit']) {
$sql = "UPDATE entries SET cat_id = " . $_POST['cat'];
. ", subject = '" . $_POST['subject'] . "',
body= '" . $_POST['body'] . "' WHERE id = " . $validentry . ";";
mysql_query($sql);
header("Location: " . $config_basedir . "/viewentry.php?id=" . $validentry);
}
else {
require("backendheader.php");
$fillsql = "SELECT * FROM entries WHERE id = " . $validentry . ";";
$fillres = mysql_query($fillsql);
$fillrow = mysql_fetch_assoc($fillres);
?>
<h1>Update Entry</h1>
<form action="<?php echo $SCRIPT_NAME . "" . $validentry; ?>" method="post">
<table>
<tr>
<td>Title</td>
<td><input type="text" name="title"
value="<?php echo $fillrow['title']; ?>">
</td>
</tr>
<tr>
<td>Body</td>
<td><textarea name="body" row="10" cols="50">
<?php echo $fillrow['body']; ?></textarea>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Update Entry!"></td>
</tr>
</table>
</form>
</div> <!-- End of main id -->
<?php
require("backendfooter.php");
?>
Parse error: syntax error, unexpected $end in updateentry.php on line 82
I believe i have isolated the problem, the error goes away when i remove this block of code. But i can't figure out what is wrong or how to fix it.
if($_POST['submit']) {
$sql = "UPDATE entries SET cat_id = " . $_POST['cat'];
. ", subject = '" . $_POST['subject'] . "',
body= '" . $_POST['body'] . "' WHERE id = " . $validentry . ";";
mysql_query($sql);
header("Location: " . $config_basedir . "/viewentry.php?id=" . $validentry);
}
else {
This is the entire script, the purpose of the script it to retrieve data from my database and fill it into the form. The user is then able to edit the information and it is saved back in the database.
<?php
session_start();
?>
<div id="leftnav">
<?php
require("leftnav.php");
?>
</div> <!-- End of leftnav id -->
<div id="main">
<?php
require("config.php");
if(isset($_SESSION['USERNAME']) == FALSE) {
header("Location: " . $config_basedir);
}
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
if(isset($_GET['id']) == TRUE) {
if(is_numeric($id) == FALSE) {
$error = 1;
}
if($error == 1) {
header("Location: " . $config_basedir);
}
else{
$validentry = $_GET['id'];
}
}
else{
$validentry = 0;
}
if($_POST['submit']) {
$sql = "UPDATE entries SET cat_id = " . $_POST['cat'];
. ", subject = '" . $_POST['subject'] . "',
body= '" . $_POST['body'] . "' WHERE id = " . $validentry . ";";
mysql_query($sql);
header("Location: " . $config_basedir . "/viewentry.php?id=" . $validentry);
}
else {
require("backendheader.php");
$fillsql = "SELECT * FROM entries WHERE id = " . $validentry . ";";
$fillres = mysql_query($fillsql);
$fillrow = mysql_fetch_assoc($fillres);
?>
<h1>Update Entry</h1>
<form action="<?php echo $SCRIPT_NAME . "" . $validentry; ?>" method="post">
<table>
<tr>
<td>Title</td>
<td><input type="text" name="title"
value="<?php echo $fillrow['title']; ?>">
</td>
</tr>
<tr>
<td>Body</td>
<td><textarea name="body" row="10" cols="50">
<?php echo $fillrow['body']; ?></textarea>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Update Entry!"></td>
</tr>
</table>
</form>
</div> <!-- End of main id -->
<?php
require("backendfooter.php");
?>