Hey
Underneith is my code, im having a problem where as when i click the delete button it does what i need it to do (delete a thead) however it also delete the 'title' fields from every other entry in my database ??

this is substantually weird
can anyone help ??

thankyou in advanced
:

<a href='delete.php?sent=true' style="margin-left:60px; font-size:14px; color:#FF0000;"><b>Click me to delete</b></a>


<?php
if ($_REQUEST == 'true') {
$query = "DELETE FROM `forumtutorial_posts` WHERE parentid = '$parentid' OR postid = '$parentid'";
if (mysql_query($query)) {
echo "<script>alert('Topic Deleted'); location.href = 'members.php'; </script>";
}
else {
echo "<script>alert('Something Went Wrong, Contact Reece Stanton'); location.href = 'members.php'; </script>";
}
}
?>

Edited 3 Years Ago by happygeek: fixed formatting

pass the auto increment id to the delete command..which is unique in your table...
or post table structure ...
and here what are those parentid and postid...
i think postid is your unique id...???

hey
thanks for the reply

yes its the auto increment id that gets stored and then used as a rope to delete the thread, and all the posts inside.

parent id is all of the posts in a thread. so if my threads postid was 1 all the posts in it would have a parent id of 1.
and the post id is simply the auto increment

i hope you can help
thans in advanced

so,you wan to delete only that post,then simple use:

$query = "DELETE FROM `forumtutorial_posts` WHERE postid = '$parentid'";

i don't know, why you are writing the below line..could you please tel me what is the reason behind that line...

parentid = '$parentid' OR

or if you want to recognize both parentid and postid then use AND instead of OR.

heyy1

i've found the problem

<?php
$parentid = $_REQUEST['delid'];
echo $parentid;
?>
<a href='delete.php?sent=true' style="margin-left:60px; font-size:14px; color:#FF0000;"><b>Click me to delete</b></a>

<?php
if ($_REQUEST['sent'] == 'true') {
$query = "DELETE FROM `forumtutorial_posts` WHERE parentid = '8' OR postid = '8'";
if (mysql_query($query)) {
echo "<script>alert('Topic Deleted'); location.href = 'members.php'; </script>";
}
else {
echo "<script>alert('Something Went Wrong, Contact Reece Stanton'); location.href = 'members.php'; </script>";
}
}   
	?>

i echod the parentid and it holds this:
?id=12

instead of this:
12

im sure this is just a simple problem
any ideas?

thanks

heyy

all its doing is deleing the post that has an postid of '12' and any other posts that parent is post '12' (parentid).

or if you want to recognize both parentid and postid then use AND instead of OR.

I have to use OR because im looking for anything with either a postid or a parent id of '12'.
If i was searching for both, it would only find the parent post, everything inside wouldnt be deleted.

I hope you understand, look at my post above i think thats the problem.

This question has already been answered. Start a new discussion instead.