Jump to content

Recommended Posts

if($_GET[delete]) {
if($mod == "0") { die('You cannot delete this topic'); }
$delete = $_GET[delete];
$cc=mysql_num_rows(mysql_query("SELECT * FROM forum_question WHERE username='$username' AND id='$delete'"));
$fet=mysql_query("SELECT * FROM forum_question AND id='$delete'");
if($mod == 2){
mysql_query("DELETE FROM forum_question WHERE id='$delete'");
mysql_query("DELETE FROM forum_answer WHERE question_id='$delete'");
mysql_query("UPDATE forum_user SET post=post-1 WHERE username='$fet->username'");
}
echo "Topic Deleted.";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=index.php'>";
}

Any idea why it dosent UPDATE forum_user SET post=post-1?

Link to comment
https://forums.phpfreaks.com/topic/206058-dosent-update-forum_user/
Share on other sites

Yes, $fet will need to be passed to mysql_fetch_object.

 

Its not the only error though. You really should check your queries actually execute before continuing. The second SELECT statement will fail, its missing any WHERE clause. It should be combined with the first one anyway for efficiencies sake.

$fet=mysql_query(mysql_fetch_object("SELECT * FROM forum_question WHERE id='$delete'"));

this now says isnt a valid mysql result resource

 

This is a terrible way of executing queries because you have no checks in place to see if they actually succeed. In fact, writing code like that leaves no opportunity to fit a check in.

 

At minimum a SELECT statement should be executed something like....

 

$sql = "SELECT * FROM forum_question WHERE id='$delete'";
if ($result = mysql_query($sql)) {
  if (mysql_num_rows($result)) {
    // $result is now safe to use in here.
  } else {
    // no results where found, handle the error
  }
} else {
  // your query failed, handle the error
}

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.