Topic: More sql problems, I cant spot what's wrong ;)
I'm doing a query in phpmyadmin, and it works, but somehow the PHP doesn't ....
What I manually gave to phpmyadmin, returned two id's 24 & 25
SELECT af.id FROM attach_12_attach_2_files AS af, attach_12_posts AS p WHERE af.post_id=p.id AND p.topic_id='3'
But this code returns an empty value!
$result_attach = $db->query('SELECT af.id FROM '.$db->prefix.'attach_2_files AS af, '.$db->prefix.'posts AS p WHERE af.post_id=p.id AND p.topic_id=\''.intval($id).'\'') or error('Error when searching for all attachments in this thread',__FILE__,__LINE__);
if($db->num_rows($result_attach)>0){
//fetch all attachment id's
while(list($attach_id)=$db->fetch_row($result_attach)&&$ok){
// loop though and delete attachment after attachment (this can take a loooong time)
error("Test 4: $attach_id <br />\n"); // just for DEBUGGING...
$ok = attach_delete_attachment($attach_id);
// break if attachment failed (then rest will become orphans, but better than a zillion of errors...
}
}
$ok is set to true at the beginning of the function, but it might be obsolete as I have replaced return false with error()'s instead...
But that error() I put there returns "Test 4: <br />" not any id's like I get in phpmyadmin
Either way ... can anyone spot the error?