Thanks laserlight. I tried using that string as well and got the same problem of the page refreshing without anything happening. I checked the code and there is nothing wrong in terms of syntax. I'm a little baffled now. I had a read through the manual and i'm not too sure about what to do. Here is the full code in case anyone has the time to have a look. It would be greatly appreciated.
<?php
{
// connect to host and select my database
$town = mysql_connect("localhost", "bubblers", "reggae")
or die ("Could not connect");
mysql_select_db ("bubblers")
or die ("Could not select database");
if($createEntry) {
echo"<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n";
echo"\t\t<p align=\"center\"><b>ADD NEWS ITEM</b><p>\n";
echo"\t\t<table width=\"500\" border=\"0\" align=\"center\">\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">Date <i>(YYYY-MM-DD)</i>\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"date\" maxlength=\"10\" size=\"28\"></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">Title\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"title\" maxlength=\"50\" size=\"50\" ></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">content\n";
echo"\t\t<td width=\"350\" align=\"right\"><textarea rows=\"15\" cols=\"40\" name=\"content\"></textarea></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">author\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"author\" maxlength=\"20\" size=\"28\"></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td colspan=\"2\" align=\"center\">\n";
echo "<input type=\"Submit\" name=\"submitCreate\" value=\"Create news item\"></td></tr>\n";
echo "</table></form>\n";
} else if ($submitCreate) {
// print submitted author
echo "<p align=\"center\">";
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value<br>\n";
}
echo "</p>";
$slash_title = addslashes($title);
$slash_content = addslashes($content);
$slash_author = addslashes($author);
// create query
$query = "INSERT INTO news (news_date,title,content,author) VALUES ('$date','$slash_title','$slash_content','$slash_author')";
//$query = stripslashes ($query);
echo "<p>queryString = $query</p>\n";
// process form
$result = mysql_query("$query")
or die ("Invalid query");
echo "<p align=\"center\"><b>Thank you! news item <i>$title</i> has been created.</b>\n";
} else if($editEntry) {
// create query
$query = "select * from news where news_id=$id";
// process form
$result = mysql_query("$query")
or die ("Invalid query");
$numOfRows = mysql_num_rows ($result)
or die ("The query: '$query' did not return data");
$row = mysql_fetch_assoc($result);
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n";
echo"\t\t<p align=\"center\"><b>EDIT NEWS ITEM</b><p>\n";
echo"\t\t<table width=\"500\" border=\"0\" align=\"center\">\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">Date <i>(YYYY-MM-DD)</i>\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"date\" maxlength=\"10\" size=\"28\" value=\"$row[news_date]\"></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">title\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"title\" value=\"$row[title]\" maxlength=\"50\" ></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">content\n";
echo"\t\t<td width=\"350\" align=\"right\"><textarea rows=\"15\" cols=\"40\" name=\"content\">$row[content]</textarea></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td width=\"150\">author\n";
echo"\t\t<td width=\"350\" align=\"right\"><input type=\"text\" name=\"author\" value=\"$row[author]\" maxlength=\"20\" size=\"20\"></td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td colspan=\"2\" align=\"center\">\n";
echo "<input type=\"Submit\" name=\"submitDelete\" value=\"Delete news\">\n";
echo "<input type=\"Submit\" name=\"submitEdit\" value=\"Update news\"></td></tr>\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$row[news_id]\">\n";
echo "</table></form>\n";
} else if ($submitEdit) {
// print submitted author
echo "<p align=\"center\">";
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value<br>\n";
}
echo "</p>";
$slash_title = addslashes($title);
$slash_content = addslashes($content);
$slash_author = addslashes($author);
// create query
$query = "UPDATE news SET content = '$slash_content', news_date = '$date', title = '$slash_title', author = '$slash_author' WHERE news_id=$id";
// process form
$result = mysql_query("$query")
or die ("Invalid query");
echo "<p align=\"center\"><b>Thank you! news item <i>$title</i> has been updated.</b>\n";
} else if ($submitDelete) {
// print submitted author
echo "<p align=\"center\">";
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value<br>\n";
}
echo "</p>";
// create query
$query = "DELETE FROM news WHERE news_id = $id";
// process form
$result = mysql_query("$query")
or die ("Invalid query");
echo "<p align=\"center\"><b>Thank you! news item <i>$title</i> has been deleted.</b>\n";
} else { // this is first screen
// create query
$query = "select * from news order by news_date desc";
// process form
$result = mysql_query("$query")
or die ("Invalid query");
$numOfRows = mysql_num_rows ($result)
or die ("The query: '$query' did not return data");
echo "<p align=\"center\"><b>NEWS ADMIN</b>\n";
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n";
echo"\t\t<table width=\"500\" border=\"0\" align=\"center\">\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td align=\"center\">Add a news item to the database</td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td align=\"center\">\n";
echo "\t<input type=\"Submit\" name=\"createEntry\" value=\"Add news item\"></td></tr>\n";
echo"\t\t</td></tr></table>\n";
echo"\t\t<p><p>\n";
echo"\t\t<table width=\"500\" border=\"0\" align=\"center\">\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td align=\"center\">Choose a news item to edit</td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td align=\"center\">\n";
echo "\t<select name=\"id\">\n";
while($row = mysql_fetch_assoc($result)) {
echo "\t\t<option value =\"$row[news_id]\">$row[news_date], $row[title]";
echo "\n";
}
echo"\t\t</td></tr>\n";
echo"\t\t<tr valign=\"top\" bgcolor=\"f0f0f0\">\n";
echo"\t\t<td align=\"center\">\n";
echo "\t<input type=\"Submit\" name=\"editEntry\" value=\"Edit news item\"></td></tr></table>\n";
echo "</form>";
}
echo "<p align=\"center\">---------------------------------------------------------\n";
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n";
echo "\t<input type=\"hidden\" name=\"password\" value=\"$password\">\n";
echo "\t<input type=\"Submit\" name=\"goBaseAdmin\" value=\"back to news admin home\">\n";
echo "<br>---------------------------------------------------------\n";
echo "</form>";
}
?>