The below code is not update the columns in my database. It executes the SELECT without any problems.
I am using almost the exact code for another form which works without any problem. The value of $id is echoed in the form, but I don't think it is being passed to the UPDATE sql. WHen I echo the UPDATE query I get a value of 1 which, to me, indicates the query is valid.
Any help you can render would be greatly appreciated.
Steve
<?php
// EDIT
include_once ("../includes/login3.php");
include_once ("../includes/functions.php");
?>
<?php
if (!isset($submitok))
{
// generate and execute query
$qryEditNews = " SELECT NewsID,Headline,Content,Date
FROM tblNews
WHERE NewsID = '$id'";
$rsltEditNews = mysql_query($qryEditNews) or die ("Error in query: $qryEditNews. " . mysql_error());
// if a result is returned
if (mysql_num_rows($rsltEditNews) > 0)
{
// turn it into an object
$EditNews_row = mysql_fetch_object($rsltEditNews);
// print form with values pre-filled
}
?>
<a class="intro" href="?action=editnews">Edit News</a>
<table cellspacing="5" cellpadding="5">
<form action="<?=$PHP_SELF?>?action=listnews" method="POST">
<tr>
<td width="109" valign="top" class="txthdr">NewsID =<?php echo $id; ?>
</td>
<td width="332" class="intro"> </td>
</tr>
<tr>
<td valign="top" class="txthdr">Headline</td>
<td class="intro"><input name="newHeadline" type="text" value="<?php echo $EditNews_row->Headline; ?>" size="75">
</tr>
<tr>
<td valign="top" class="txthdr">Content</td>
<td class="intro"><textarea cols="75" rows="20" name="newContent"><?php echo $EditNews_row->Content; ?></textarea></td>
</tr>
<tr>
<td colspan=2><input type="Submit" name="submitok" value="Update"></td>
</tr>
</form>
</table>
<?php
}
else
{
if ($newHeadline=="" or $newContent=="") {
error("One or more required fields were left blank.\n".
"Please fill them in and try again.");
}
$qUpdateNews = mysql_query ("UPDATE tblNews
SET Headline = '$newHeadline', newContent = '$newContent'
WHERE NewsID = '$id'");
echo "<font size=-1>Update successful.</a>.</font>";
}
?>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="12" colspan="2" valign="top" bgcolor="#163BA3"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="100%" height="54" valign="top">
<?php
include_once ("../includes/footer.php");
?>
</td>
</tr>
</table>