delete a comment you posted with the php code?


I was wondering if you can maybe help me out here... I created a link sharing website and managed to create a comment on a shared link.

I want to give you a scenario of what I would like to achieve. Every comment made by user_1 for instance, can only be deleted by user_1 and admin.

I understand that when "deleting" it from the php page it must also be dropped from the database. How can you do this?

//I pressume where I INSERTED my post's 'vales' I must DELETE them again from there??
//It is very much alike from reply.php's code where you INSERT the data into the database. Now I just want to delete it.
//I don't know if this code below is correct??

        WHERE ('" . $_POST['reply-content'] . "',
                " . mysql_real_escape_string($_GET['id']) . ",
                " . $_SESSION['user_id'] . ")";

$result = mysql_query($sql);

    echo 'Your reply has not been saved, please try again later.';
    echo 'Your comment has been deleted!';

Your Delete query has major syntax errors. You don't delete individual fields from a table - you CAN'T. you can only delete entire records. The proper syntax is:

DELETE FROM sometable WHERE (...)

Your where clause also has errors. You're not doing any comparison operations, just listing some values. Again, a syntax error. Most like you'd want this (guessing at your post's table primary key field name):

DELETE FROM posts WHERE (post_id = $id);