Jump to content

Comment Mod System Effects all rows...


DiscoTrio

Recommended Posts

Sorry if its confusing but here is whats going on:  I have a table in a database called comments and there are alot of entries there but can manually be marked flagged with a 1.  Nvm how that is done, but I made it so the comments are printed on a pass protected page with two links below them.  Ignore is supposed to mark that comment with a 0, and delete deletes the row.

 

Everything works fine but the action happens to ALL the comments that are shown.  Can anyone see why that is happening?

 

<?
if($session->isAdmin()){?>
<center><font face="Papyrus" size="5">MOD Center</font></center>
<center><a href='mod1.php'>[News Aproval]</a>  <a href='mod2.php'>[Flagged Items]</a></center>
<?$con = mysql_connect("localhost","bmvybfbk_master","74SAc194G");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("bmvybfbk_website", $con);

$result = mysql_query("SELECT * FROM comments WHERE flagged = '1'");

while($row = mysql_fetch_array($result))

  {
    $cnumber = $row['id'];
  echo $row['writer'] . " wrote:<br>" . $row['comment'];
  echo "<br><a href='mod2.php?action=ignore'>[ignore]</a>";
  echo " <a href='mod2.php?action=delcomment'>[Delete]</a>";
  echo "<br>----------------------------------------------------------------------------------------------------<br>";
  
  
  if ($action == ignore) {
mysql_query("UPDATE comments SET flagged = '0' WHERE id = '$cnumber' LIMIT 1");}

if ($action == delcomment) {mysql_query("DELETE FROM comments WHERE id='$cnumber' LIMIT1");}

else {echo " ";}
  
  }
}else{ echo "*You Don't Have any rights to View this page*'"; } ?>

Link to comment
Share on other sites

Where are you getting the $cnumber variable from?  I'm assuming you getting it from the url (/my/url?cnumber=123).  In this case, you may need to get the variable from the $_GET superglobal since register_globals may be turned off (and should be left off for security reasons).

 

$cnumber = $_GET['cnumber'];

 

You should also use error_reporting(E_ALL) to check for any missing variables or small errors.

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.