Jump to content

Help needed


marcus

Recommended Posts

Fourth time with no help, again, I will try to post this.

Problem: Comments will not delete.
Situation: Administrative comment deletion. Administrators can delete comments, the comments will not delete.

Code:
[code]
<? include('../header.php'); ?>
<?php
if($_COOKIE[admin]){

$action = $_GET[act];
$act = $_POST[act];


if($action == delete){
$NFin = "SELECT * FROM `news` WHERE `comments` =1";
$NFgo = mysql_query($NFin);
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "No active news";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<form name=delcomfnews action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 1</h3>";
echo "<tr><td>";
echo "<select name=delcomnews>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<option value=$row1[id]>$row1[title]</option>";
};
mysql_free_result($NFgo);
echo "<td><input type=hidden name=act value=dels1><input type=submit value='Show Comments'>";
echo "</form>";
echo "</table>";
};
}else

if($act == dels1){
$NFid = $_POST[delcomnews];
$NFin = "SELECT * FROM `comments` WHERE newsid ='$NFid'";
$NFgo = mysql_query($NFin) or die(mysql_error());
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "There are no comments for news ID #$NFid";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 2</h3>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<tr><td>Posted by: $row1[poster]<td>($row1[ip])";
echo "<tr><td colspan=2 align=left>$row1[message]";
echo "<form name=delcom action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<input type=hidden name=act value=delcomgo>";
echo "<tr><td colspan=2 align=right><input type=hidden name=newid value=$NFid><input type=hidden name=comid value=$row1[id]><input type=submit value='Delect Comment #"."$row1[id]"."'>";
echo "</form>";
}
mysql_free_result($NFgo);
echo "</table>";
}

if($act == delcomgo){
$comid = $_POST[comid];
$newid = $_POST[newid];
$DELcom = "DELETE FROM `comments` WHERE id =$comid";
$DELsql = mysql_query($DELcom) or die(mysql_error());
$sql1 = "SELECT camount FROM `news` WHERE id =$newid";
$sql2 = mysql_query($sql1);
$sql3 = mysql_fetch_assoc($sql2);
$sql4 = $sql3[camount];
$sql5 = "$sql4 - 1";
$sql6 = "UPDATE `news` SET camount ='$sql5' WHERE id=$newid";
$sql7 = mysql_query($sql6);
echo "Comment ID #$comid has been deleted!";
};

}else if(!$act || !$action){
echo "<table border=0 cellspacing=3 cellpadding=2>";
echo "<tr><td colspan=2 align=right><h3>Comment Admin</h3>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=edit>Edit Comments</a>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=delete>Delete Comments</a>";
echo "</table>";
};



}else {
echo "Bad auth";
};
?>
<? require('../footer.php'); ?>
[/code]
Link to comment
Share on other sites

if you embed an array into a string like that, you have to put {} around it, or PHP will read up to the point it sees the [ character and then stop, and try to display the "$row1" (which will be an array, so it wont display correctly) you have to tell it to keep looking...

eg
if you do

$array['index']

php sees

$array

so you gotta do {$array['index']}

can be seen in the echo example here: http://www.php.net/manual/en/function.echo.php
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.