Thanks for the help before the '".$_GET['id']."'"; certainly fixed all the problems
regarding the display of stories and I have ammended my othe files similarly but I am
having I think syntax problems with the add and edit parts. I'm sure its just a case
of using the GET part again but am having some difficulty.
Thanks in Advance.
Code below
This is the correction made so far which displays stories, deletes and displays
stories in the edit dialog
//$query = "SELECT slug, content, contact, timestamp FROM news WHERE id = '$id'";
$query = "SELECT slug, content, contact, timestamp FROM news WHERE id =
'".$_GET['id']."'";
This is the add part:
// add.php - add a new press release
?>
Megalomaniacs Inc :
Administration : Press Releases : Add
Slug
Content
Contact person
Update successful. Go back to the
main menu.";
// close database connection
mysql_close($connection);
}
else
{
// errors found
// print as list
echo "The following errors were encountered: ";
echo "";
for ($x=0; $x$errorList[$x]";
}
echo "";
}
}
?>
This is the Edit part where the Update statement doesn't work although it retrieves
the record in the editable formats.
// edit.php - edit a press release
?>
Megalomaniacs Inc :
Administration : Press Releases : Edit
0)
{
// turn it into an object
$row = mysql_fetch_object($result);
// print form with values pre-filled
?>
Slug
Content
content;
?>
Contact person
That press release could not be located in our
database.";
}
}
// form submitted
// start processing it
else
{
// set up error list array
$errorList = array();
$count = 0;
// validate text input fields
if (!$slug) { $errorList[$count] = "Invalid entry: Slug"; $count++; }
if (!$content) { $errorList[$count] = "Invalid entry: Content"; $count++; }
// set default value for contact person
if (!$contact) { $contact = $def_contact; }
// check for errors
// if none found...
if (sizeof($errorList) == 0)
{
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to
connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
//$query = "SELECT slug, content, contact, timestamp FROM news WHERE
id = '".$_GET['id']."'";
$query = "UPDATE news SET slug = '$slug', content = '$content',
contact = '$contact', timestamp = NOW() WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
// print result
echo "Update successful. Go back to the
main menu.";
// close database connection
mysql_close($connection);
}
else
{
// errors occurred
// print as list
echo "The following errors were encountered: ";
echo "";
for ($x=0; $x$errorList[$x]";
}
echo "";
}
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php