How do you delete a script?

Help with php delete script!!!!?

  • I am trying to delete multiple records on a forum with check boxes, but the code is not working. It is saying it has successfully been deleted but it doesn't delete the posts. Please help, 10 points for the best answer. $check="SELECT * FROM posts WHERE category_id='".$cid."' AND ID= '".$tid."'"; $result= mysql_query($check) or die(mysql_error()); $rows= mysql_fetch_assoc($result); $post_id=$rows['ID']; <input name='checkbox[]' type='checkbox' value='$post_id' /> if(isset($_POST['delete'])){ $checkbox=$_POST['checkbox']; $count_ids = count($_POST['checkbox']); //counting how many checkboxes have been selected. for($i=0;$i<$count_ids;$i++){ $del_id=$checkbox[$i]; $sqldelete = "DELETE from posts WHERE ID = $del_id"; $res4= mysql_query($sqldelete); echo"You have succsesfully deleted the selected post"; } ID is the ID of the post that someone has done.

  • Answer:

    You need to provide you're self some feed back I would add a conditional statement if($res4) { echo "You have successfully deleted the selected post"; } else { echo "failed"; // you can then start using mysql_error if you're on a development site } Just as a side note ALWAYS ESCAPE your input - regardless where it came from

Dan at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.