INSERT not working

admin

Administrator
Staff member
Help!

Here's the middle part of my code. It is failing in the second line after the "mysql_query ("INSERT INTO Announcements"... command so I assume it has something to do with the syntax of the VALUE part of the insert. It did insert when I used values like '$row[1]' instead of '$row['email']' but it didn't put things in the right place. What am I doing wrong?

thanks in advance. -craig

while (list($key, $val) = each($HTTP_POST_VARS)) {
echo "$key => $val<BR>";
list ($action, $ID) = split ('@', $val);
echo "action: $action<BR>ID: $ID<BR>";
if ($action == "delete") {
$delete = mysql_query ("DELETE FROM pendingAnnouncements
WHERE (ID='$ID')") or die ("DELETE *not* successful");
echo "successfully deleted record $ID<BR><BR>\n";
} else if ($action == "approve") {
$result = mysql_query ("SELECT username, email, startdate, enddate, title, titleFontSize,
titleFontColor, contentAlign, link, contentText, enchtmlannc, contentFontSize, contentFontColor
FROM pendingAnnouncements WHERE (ID='$ID')");
$row = mysql_fetch_array ($result);
mysql_query ("INSERT INTO Announcements
(ID, username, email, startdate, enddate, title, titleFontSize, titleFontColor, contentAlign,
link, contentText, enchtmlannc, contentFontSize, contentFontColor) VALUES (NULL, '$row['username']',
'$row['email']', '$row['startdate']', '$row['enddate']', '$row['title']',
'$row['titleFontSize']', '$row['titleFontColor']', '$row['contentAlign']', '$row['link']',
'$row['contentText']', '$row['enchtmlannc']', '$row['contentFontSize']', '$row['contentFontColor']')");
echo "<B>moved record $ID to approved announcements database</B><BR>\n";
$delete = mysql_query ("DELETE FROM pendingAnnouncements
WHERE (ID='$ID')") or die ("DELETE *not* successful");
echo "deleted record from pending database<BR><BR>\n";
} else {
echo "<BR><BR>\n";
}
}
 
Back
Top