rarg....i'm getting asn sql error when trying to delete a post with an attachment...
here is the lines....10 above and below in functions...
PHP Code:
// ###################### Start delete post #######################
function deletepost($postid,$countposts=1,$threadid=0) {
global $DB_site;
// decrement user post count
if ($postinfo=getpostinfo($postid)) {
if ($countposts) {
$storeadmin = $DB_site->query_first("SELECT newreply FROM storeadmin");
$storem=$storeadmin[newreply];
$DB_site->query("UPDATE user SET posts=posts-1,storep=storep-'$storem' WHERE userid='$postinfo[userid]'");
}
if ($postinfo['attachmentid']) {
// make sure you don't remove attachments still in use $att = explode(",",$postinfo[attachmentid]);
foreach($att as $value) {
if(isset($qry)) {
$qry .= " OR attachmentid='$value'";
} else {
$qry = "attachmentid='$value'";
}
}
$otherattachs=$DB_site->query("SELECT attachmentid FROM post WHERE $qry AND threadid<>'$postinfo[threadid]'");
if ($DB_site->num_rows($otherattachs)==0) {
$DB_site->query("DELETE FROM attachment WHERE $qry");
$DB_site->query("UPDATE thread SET attach = attach - 1 WHERE threadid = '$threadid'");
}
}
$DB_site->query("DELETE FROM post WHERE postid='$postid'");
}
}
any idea?