Reply
Unexpected $end - custom blog
Old 05-17-2008, 02:55 PM Unexpected $end - custom blog
AcidX's Avatar
Novice Talker

Posts: 8
Name: WillJB
Location: England, UK
Hey people.

I recently embarked on the creation of a custom PHP/SQL powered blog but am having a few troubles getting it running. It runs via two PHP pages using actions. One works fine (the log in area) however, when trying to work the main page it retrieves this fateful error:
Quote:
Parse error: syntax error, unexpected $end in /home/willjb/public_html/index.php on line 480
Common problem to which I can't find a solution, myself. My own guess is that something, such as a bracket, has been left unclosed. I've had a good look and can't find it though. I'm kinda getting sick of it after looking at it for a good few hours now so here's my code (minus header & footer) for anyone who wants to give it a shot.

PHP Code:
<?php session_start(); ?>
  
<?php
  
$max_items 
10;

$db mysql_connect ('localhost','USERNM','PASSWRD');
mysql_select_db ('willjb_blog',$db);


function 
displayNews($all) {

global 
$db$max_items;

if (
$all == 0) {

$query "SELECT id, title, newstext," "DATE_FORMAT(postdate, '%b %e, %Y') as date " "FROM news ORDER BY id DESC LIMIT $max_items";

} else {
$query "SELECT id, title, newstext," "DATE_FORMAT(postdate, '%b %e, %Y') as date " "FROM news ORDER BY id DESC";
}
$result mysql_query ($query);
while (
$row mysql_fetch_assoc ($result)) {
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";


$date $row['date'];
$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);
$id $row['id'];

echo 
"<TR><TD><p><a href=\"{$_SERVER['PHP_SELF']}" "?action=show&id=$id\"<b>$title</b></a> posted on <i>$date</i></p></TD>\n";
echo 
"\n";


$comment_query "SELECT count(*) FROM news_comments " "WHERE news_id={$row['id']}";
$comment_result mysql_query ($comment_query);
$comment_row mysql_fetch_row($comment_result);

echo 
"<TD algin=\"right\"><p><a href=\"{$_SERVER['PHP_SELF']}" "?action=showcom&id={$row['id']}\">Comments</a> " "{" "$comment_row[0]}</p></TD></TR>\n";

echo 
"</TABLE>\n";
echo 
"\n";
}

if (
$all == 0) {
echo 
"<br /><center><a href=\"{$_SERVER['PHP_SELF']}" "?action=all\">View all news</a></center>\n";
}
}


function 
displayOneItem($id) {
global 
$db;
$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);


if (
mysql_num_rows ($result) == 0) {
echo 
"<center><b>Error!</b></center>\n";
echo 
"<p>No News Exists for the ID specified. Please try again.</p>\n";
return;
}
$row mysql_fetch_assoc($result);
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);

echo 
"<TR><TD align=\"center\"><b><p>$title</p></b></TD></TR>\n";
echo 
"<tr><td align=\"center\"><p><<<------------------------------------------->>></p></td></tr>\n";
echo 
"<TR><TD><p>$news</p></TD></TR>\n";

echo 
"</TABLE>\n";
echo 
"<BR>\n";



echo 
"<Center>";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{
echo 
"<hr color=\"#666666\" width=\"50%\" />";
echo 
"&rarr; <b><a href=\"index.php?action=editnews129&id=$id\">Edit News</a></b>
--
<b><a href=\"index.php?action=deletenews129&id=$id\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete News</a></b> &larr;"
;
echo 
"<hr color=\"#666666\" width=\"50%\" />";

}
echo 
"</center>";

echo 
'<center><a href="' $_SERVER[PHP_SELF] . '?action=showcom&id=' $id '">Show Comments</a></center>';
}
function 
displayOneItem_withComments($id) {
global 
$db;

$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);

if (
mysql_num_rows ($result) == 0) {
echo 
"<center><b>Error!</b></center>\n";
echo 
"<p>No News Exists for the ID specified. Please try again.</p>\n";
return;
}
$row mysql_fetch_assoc($result);
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);

echo 
"<TR><TD align=\"center\"><b><p>$title</p></b></TD></TR>\n";
echo 
"<tr><td align=\"center\"><p><<<------------------------------------------->>></p></td></tr>\n";
echo 
"<TR><TD><p>$news</p></TD></TR>\n";
echo 
"</TABLE>\n";
echo 
"<BR>\n";


echo 
"<Center>";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{
echo 
"<hr color=\"#666666\" width=\"50%\" />";
echo 
"&rarr; <b><a href=\"index.php?action=editnews129&id=$id\">Edit News</a></b>
--
<b><a href=\"index.php?action=deletenews129&id=$id\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete News</a></b> &larr;"
;
echo 
"<hr color=\"#666666\" width=\"50%\" />";

}
echo 
"</center>";
displayComments($id);
}
function 
displayComments($id) {

global 
$db;

$query "SELECT * FROM news_comments WHERE news_id=$id";
$result mysql_query ($query);

echo 
'<center><a href="' $_SERVER[PHP_SELF] . '?action=show&id=' $id '">Show without Comments</a></center>';
echo 
"<center><h3>Comments</h3><HR width=\"100%\"></center>\n";

while (
$row mysql_fetch_assoc ($result)) {
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$name htmlentities ($row['name']);
echo 
"<TR><TD><u>Posted by <b>$name</b></u>";

echo 
"</TD></TR>\n";

$comment strip_tags ($row['comment'], '<a><b><i><u>');
$comment nl2br ($comment);
echo 
"<TR><TD><p>$comment</p></TD></TR>\n";
echo 
"<tr><td align=\"left\" valign=\"top\">";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{

echo 
"<p>&larr; <a href=\"index.php?action=editcom129&id={$row['id']}\">Edit Comment</a> -- <a href=\"index.php?action=deletecom129&id={$row['id']}\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete Comment</a> &rarr;</p>";
}
echo 
"</tr></td>";
echo 
"<tr><td><p>====================================================</p></td></tr>\n";

echo 
"</TABLE>\n";
echo 
"\n";
function 
addComment($id) {
global 
$db;

$query "INSERT INTO news_comments " "VALUES('',$id,'{$_POST['name']}'," "'{$_POST['comment']}')";
mysql_query($query);
echo 
"Comment entered. Thanks!<BR>\n";
echo 
"<center><a href=\"{$_SERVER['PHP_SELF']}" "?action=showcom&id=$id\">Back</a></center>\n";
}

function 
addnews129($id) {

global 
$db;

session_start();
if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficeint permission to view this page.';

}else{

$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);
echo 
"<center><h3>Add News</h3></center>\n";
echo 
"<div align=\"left\">";
echo 
"There are 4 types of add-ins allowed to be used. They are: <ul>";
echo 
"<li>&lt;b&gt;<b>BOLD</b>&lt;/b&gt; </li>";
echo 
"<li>&lt;i&gt;<i>ITALIC</i>&lt;/i&gt; </li>";
echo 
"<li>&lt;u&gt;<u>UNDERLINED</u>&lt;/u&gt; </li>";
echo 
"<li>&lt;a href=\"http://www.somesite.com\"&gt;<a href=\"http://www.somesite.com\">NAME OF SOMESITE</a>&lt;/a&gt;</li></ul>";
echo 
"</div>";
echo 
"<center><FORM action=\"{$_SERVER['PHP_SELF']}" "?action=addnews\" method=POST>\n";
echo 
"Title: <input type=\"text\" " "size=\"30\" name=\"title\"><BR>\n";
echo 
"<TEXTAREA cols=\"40\" rows=\"15\" " "name=\"news\"></TEXTAREA><BR>\n";
echo 
"<input type=\"submit\" name=\"submit\" " "value=\"Add News\"\n";
echo 
"</FORM></center>\n";
}

}


function 
addnews($id) {
global 
$db;

$title $_POST['title'];
$newstext $_POST['news'];
$query "INSERT INTO news (postdate, title, newstext)" "VALUES(NOW(), '$title', '$newstext')";
$result mysql_query($query);

if(
$result){
echo 
"<center>News Submitted</center><BR>\n";
echo 
"<center><a href=\"{$_SERVER['PHP_SELF']}\">Back</a></center>\n";
}else{
echo 
'Error! Something\'s wrong with the database or something!<br /><br /><b>';
echo 
mysql_error();
echo 
'</b>';

}
}


function 
editnews129($id) {
global 
$db;

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficient permission to view this page.';
}else{

$query "SELECT * FROM news WHERE id='$id'";
$result mysql_query ($query) or die('Error! <b>' mysql_error() . '</b>');
$row mysql_fetch_assoc ($result);
$title $row['title'];
$body $row['newstext'];
$title stripslashes($title);
$body nl2br($body);
$body strip_tags($body'<a><b><i><u>');
echo 
"<center><h3>Edit News Topic</h3><br /><b>$topic</b></center>";
echo 
"<table width=\"65%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
echo 
"<form action=\"index.php?action=editnews\" method=\"post\">";
echo 
"<tr><td>Title: </td><td><input type=\"text\" size=\"25\" name=\"title\" value=\"$title\" /></td></tr>\n";
echo 
"<tr><td>News Body: </td><td><textarea cols=\"40\" rows=\"15\" name=\"news\">$body</textarea></td></tr>\n";
echo 
"<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submitted\" value=\" Submit \" /></td></tr>\n";
echo 
"<input type=\"hidden\" value=\"submitted\" />";
echo 
"</form>";
echo 
"</table>";
echo 
"<form action=\"index.php?action=editnews\" method=\"get\">";
echo 
"<input type=\"hidden\" value=\"$id\" name=\"$id\" />";
echo 
"</form>";
}
}
function 
editnews($id) {
global 
$db;

$title $_POST['title'];
$newso $_POST['news'];
$newso strip_tags($newso'<a><b><i><u>');

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficient permission to view this page.';
}else{
if(isset(
$_POST['submitted'])){
$query "SELECT id FROM news WHERE title='$title' LIMIT 1";
$result mysql_query($query);
$row mysql_fetch_assoc($result);
$id $row['id'];
$date $row['postdate'];
$query "UPDATE news SET newstext='$newso', title='$title' WHERE id='$id' LIMIT 1";
$result mysql_query($query);

if(
$result) {
$title stripslashes($title);
echo 
"News topic <a href=\"index.php?action=show&id=$id\"><B>$title</B></a> has been updated. <br /> <center><a href=\"index.php\">Go Back</a></center>";
}else{
echo 
'Error! <b>' mysql_error() . '</b>';

}
}
}
}

function 
deletenews129($id) {
if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"<center><h3>Error!</h3></center> <br />You cannont view this page because you do not have proper identification. Please login.";
}else{
$query "DELETE FROM news WHERE id='$id' LIMIT 1";
$result mysql_query($query);
if(
$result) {
echo 
"The news you have select to delete has been successfully deleted.<br /> Either <a href=\"index.php\">Go back</a> or go to your <a href=\"/admin_login.php\">Admin Panel</a>";
}else{
echo 
'Error! <b>' mysql_error() . '</b>';
}
}
}


function 
deletecom129($id) {
if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"<center><h3>Error!</h3></center> <br />You cannont view this page because you do not have proper identification. Please login.";
}else{
$query "DELETE FROM news_comments WHERE id='$id' LIMIT 1";
$result mysql_query($query);
if(
$result) {
echo 
"The Comment you have select to delete has been successfully deleted.<br /> Either <a href=\"index.php\">Go back</a> or go to your <a href=\"/admin_login.php\">Admin Panel</a>";
}else{
echo 
'Error! <b>' mysql_error() . '</b>';
}
}
}


function 
editcom129($id) {
global 
$db;

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficient permission to view this page.';
}else{

$query "SELECT * FROM news_comments WHERE id='$id'";
$result mysql_query ($query) or die('Error! <b>' mysql_error() . '</b>');
$row mysql_fetch_assoc ($result);
$name $row['name'];
$comment $row['comment'];
$name stripslashes($name);
$comment nl2br($comment);
$comment strip_tags($comment'<a><b><i><u>');
echo 
"<center><h3>Edit Comment by</h3></center>";

echo 
"<table width=\"65%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
echo 
"<form action=\"index.php?action=editnews\" method=\"post\">";
echo 
"<tr><td>Name: </td><td><input type=\"text\" size=\"25\" name=\"name\" value=\"$name\" /></td></tr>\n";
echo 
"<tr><td>Comment: </td><td><textarea cols=\"40\" rows=\"15\" name=\"comment\">$comment</textarea></td></tr>\n";
echo 
"<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submitted\" value=\" Submit \" /></td></tr>\n";
echo 
"<input type=\"hidden\" value=\"submitted\" />";
echo 
"</form>";
echo 
"</table>";
echo 
"<form action=\"index.php?action=editnews\" method=\"get\">";
echo 
"<input type=\"hidden\" value=\"$id\" name=\"$id\" />";
echo 
"</form>";
}
}
function 
editcom($id) {
global 
$db;

$comment $_POST['comment'];
$name $_POST['name'];
$comment strip_tags($comment'<a><b><i><u>');

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficeint permission to view this page.';
}else{
if(isset(
$_POST['submitted'])){
$query "SELECT id FROM news_comments WHERE comment='$comment' LIMIT 1";
$result mysql_query($query);
$row mysql_fetch_assoc($result);
$id $row['id'];

$query "UPDATE news_comments SET comment='$comment', name='$name' WHERE id='$id' LIMIT 1";
$result mysql_query($query);
if(
$result) {
$name stripslashes($name);

echo 
"Comment has been updated. <br /> <center><a href=\"index.php\">Go Back</a></center>";
}else{
echo 
'Error! <b>' mysql_error() . '</b>';

}
}
}
}


switch(
$_GET['action']) {

case 
'show':
displayOneItem($_GET['id']);
break;
case 
'showcom':
displayOneItem_withComments($_GET['id']);
break;
case 
'all':
displayNews(1);
break;
case 
'editnews129':
editnews129($_GET['id']);
break;
case 
'editnews':
editnews();
break;
case 
'deletenews129':
deletenews129($_GET['id']);
break;
case 
'addcomment':
addComment($_GET['id']);
break;
case 
'deletecom129':
deletecom129($_GET['id']);
break;
case 
'editcom129':
editcom129($_GET['id']);
break;
case 
'editcom':
editcom();
break;
case 
'addnews':
addnews();
break;
case 
'addnews129':
addnews129();
break;
default:
displayNews();
}

?>
Also, I don't know whether the database name is written correctly or not?
That's the full name of my database, as listed in cPanel, but I've also tried it as _blog and blog - only to recieve the same error.
Anyone got any ideas?

Cheers ~
AcidX is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-17-2008, 04:37 PM Re: Unexpected $end - custom blog
rogem002's Avatar
Webmaster Talker

Posts: 569
Name: Mike
Location: United Kingdom
You have missed a } somewhere ^^

Try tabbing your code to find were it's missing.

** Edit, I took a little look. Try this: **

PHP Code:
<?php session_start(); ?>
  
<?php
  
$max_items 
10;

$db mysql_connect ('localhost','USERNM','PASSWRD');
mysql_select_db ('willjb_blog',$db);


function 
displayNews($all) {

global 
$db$max_items;

if (
$all == 0) {

$query "SELECT id, title, newstext," "DATE_FORMAT(postdate, '%b %e, %Y') as date " "FROM news ORDER BY id DESC LIMIT $max_items";

} else {
$query "SELECT id, title, newstext," "DATE_FORMAT(postdate, '%b %e, %Y') as date " "FROM news ORDER BY id DESC";
}
$result mysql_query ($query);
while (
$row mysql_fetch_assoc ($result)) {
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";


$date $row['date'];
$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);
$id $row['id'];

echo 
"<TR><TD><p><a href=\"{$_SERVER['PHP_SELF']}" "?action=show&id=$id\"<b>$title</b></a> posted on <i>$date</i></p></TD>\n";
echo 
"\n";


$comment_query "SELECT count(*) FROM news_comments " "WHERE news_id={$row['id']}";
$comment_result mysql_query ($comment_query);
$comment_row mysql_fetch_row($comment_result);

echo 
"<TD algin=\"right\"><p><a href=\"{$_SERVER['PHP_SELF']}" "?action=showcom&id={$row['id']}\">Comments</a> " "{" "$comment_row[0]}</p></TD></TR>\n";

echo 
"</TABLE>\n";
echo 
"\n";
}

if (
$all == 0) {
echo 
"<br /><center><a href=\"{$_SERVER['PHP_SELF']}" "?action=all\">View all news</a></center>\n";
}
}


function 
displayOneItem($id) {
global 
$db;
$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);


if (
mysql_num_rows ($result) == 0) {
echo 
"<center><b>Error!</b></center>\n";
echo 
"<p>No News Exists for the ID specified. Please try again.</p>\n";
return;
}
$row mysql_fetch_assoc($result);
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);

echo 
"<TR><TD align=\"center\"><b><p>$title</p></b></TD></TR>\n";
echo 
"<tr><td align=\"center\"><p><<<------------------------------------------->>></p></td></tr>\n";
echo 
"<TR><TD><p>$news</p></TD></TR>\n";

echo 
"</TABLE>\n";
echo 
"<BR>\n";



echo 
"<Center>";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{
echo 
"<hr color=\"#666666\" width=\"50%\" />";
echo 
"&rarr; <b><a href=\"index.php?action=editnews129&id=$id\">Edit News</a></b>
-- 
<b><a href=\"index.php?action=deletenews129&id=$id\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete News</a></b> &larr;"
;
echo 
"<hr color=\"#666666\" width=\"50%\" />";

}
echo 
"</center>";

echo 
'<center><a href="' $_SERVER[PHP_SELF] . '?action=showcom&id=' $id '">Show Comments</a></center>';
}
function 
displayOneItem_withComments($id) {
global 
$db;

$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);

if (
mysql_num_rows ($result) == 0) {
echo 
"<center><b>Error!</b></center>\n";
echo 
"<p>No News Exists for the ID specified. Please try again.</p>\n";
return;
}
$row mysql_fetch_assoc($result);
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$title htmlentities ($row['title']);
$news strip_tags ($row['newstext'], '<a><b><i><u>');
$news nl2br ($news);

echo 
"<TR><TD align=\"center\"><b><p>$title</p></b></TD></TR>\n";
echo 
"<tr><td align=\"center\"><p><<<------------------------------------------->>></p></td></tr>\n";
echo 
"<TR><TD><p>$news</p></TD></TR>\n";
echo 
"</TABLE>\n";
echo 
"<BR>\n";


echo 
"<Center>";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{
echo 
"<hr color=\"#666666\" width=\"50%\" />";
echo 
"&rarr; <b><a href=\"index.php?action=editnews129&id=$id\">Edit News</a></b>
-- 
<b><a href=\"index.php?action=deletenews129&id=$id\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete News</a></b> &larr;"
;
echo 
"<hr color=\"#666666\" width=\"50%\" />";

}
echo 
"</center>";
displayComments($id);
}
function 
displayComments($id) {

global 
$db;

$query "SELECT * FROM news_comments WHERE news_id=$id";
$result mysql_query ($query);

echo 
'<center><a href="' $_SERVER[PHP_SELF] . '?action=show&id=' $id '">Show without Comments</a></center>';
echo 
"<center><h3>Comments</h3><HR width=\"100%\"></center>\n";

while (
$row mysql_fetch_assoc ($result)) {
echo 
"<TABLE border=\"0\" width=\"400\" align=\"center\">\n";

$name htmlentities ($row['name']);
echo 
"<TR><TD><u>Posted by <b>$name</b></u>";

echo 
"</TD></TR>\n";

$comment strip_tags ($row['comment'], '<a><b><i><u>');
$comment nl2br ($comment);
echo 
"<TR><TD><p>$comment</p></TD></TR>\n";
echo 
"<tr><td align=\"left\" valign=\"top\">";

if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
"";
}else{

echo 
"<p>&larr; <a href=\"index.php?action=editcom129&id={$row['id']}\">Edit Comment</a> -- <a href=\"index.php?action=deletecom129&id={$row['id']}\" onClick=\"return confirm('Are you sure you really want to start to try to delete this valuable piece of information that can never be retrieved no matter how hard I trys?')\">Delete Comment</a> &rarr;</p>";
}
echo 
"</tr></td>";
echo 
"<tr><td><p>====================================================</p></td></tr>\n";

echo 
"</TABLE>\n";
echo 
"\n";
function 
addComment($id) {
global 
$db;

$query "INSERT INTO news_comments " "VALUES('',$id,'{$_POST['name']}'," "'{$_POST['comment']}')";
mysql_query($query);
echo 
"Comment entered. Thanks!<BR>\n";
echo 
"<center><a href=\"{$_SERVER['PHP_SELF']}" "?action=showcom&id=$id\">Back</a></center>\n";
}

function 
addnews129($id) {

global 
$db;

session_start();
if(!isset(
$_SESSION['admin']) && !isset($_SESSION['password'])){
echo 
'<center><h3>Error!</h3></center>You do not have sufficeint permission to view this page.';

}else{

$query "SELECT * FROM news WHERE id=$id";
$result mysql_query ($query);
echo 
"<center><h3>Add News</h3></center>\n";
echo 
"<div align=\"left\">";
echo 
"There are 4 types of add-ins allowed to be used. They are: <ul>";
echo 
"<li>&lt;b&gt;<b>BOLD</b>&lt;/b&gt; </li>";
echo 
"<li>&lt;i&gt;<i>ITALIC</i>&lt;/i&gt; </li>";
echo 
"<li>&lt;u&gt;<u>UNDERLINED</u>&lt;/u&gt; </li>";
echo 
"<li>&lt;a href=\"http://www.somesite.com\"&gt;<a href=\"http://www.somesite.com\">NAME OF SOMESITE</a>&lt;/a&gt;</li></ul>";
echo 
"</div>";
echo 
"<center><FORM action=\"{$_SERVER['PHP_SELF']}" "?action=addnews\" method=POST>\n";
echo 
"Title: <input type=\"text\" " "size=\"30\" name=\"title\"><BR>\n";
echo 
"<TEXTAREA cols=\"40\" rows=\"15\" " "name=\"news\"></TEXTAREA><BR>\n";
echo 
"<input type=\"submit\" name=\"submit\" " "value=\"Add News\"\n";
echo 
"</FORM></center>\n";
}

}


function 
addnews($id) {
global 
$db;

$title $_POST['title'];
$newstext $_POST['news'];
$query "INSERT INTO news (postdate, title, newstext)" "VALUES(NOW(), '$title', '$newstext')";
$result mysql_query($query);

if(
$result){
echo 
"<center>News Submitted</center><BR>\n";
echo 
"<center><a href=\"{$_SERVER['PHP_SELF']}\">Back</a></center>\n";
}else{
echo 
'Error!