PHP delete from comment box not working?
-
Please can someone help me with this. I am trying to delete the comments someone adds on my comment box, but they won't go from my database, can somone see if my code is ok.. <?php require("connect.php"); $name=$_POST["name"]; $comment=$_POST["comment"]; $submit=$_POST["submit"]; if($submit) { if($name&&$comment) { $insert=mysql_query("INSERT INTO comment(name,comment)VALUES('$name','$co… } else { echo "Please fill out all fields"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-… <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" type="text/css" title="default" href="images/default.css"> <link rel="alternate stylesheet" type="text/css" title="large" href="images/large.css"> <link rel="lowvision stylesheet" type="text/css" title="lowvision" href="images/lowvision.css"> <title>Comment Box</title> </head> <body> <form action="index.php"method="POST"> <table> <tr><td>Name: </td> <td><input type="text" name="name"/></td></tr> <tr><td colspan="2">Comment: </td></tr> <tr><td colspan="2"><textarea name="comment"></textarea></td></tr> <tr><td colspan="2"><input type="submit" name="submit" value="Comment"/></td></tr> </table> </form> <?php require("connect.php"); mysql_select_db("se211001"); $getquery=mysql_query("SELECT * FROM `comment` ORDER BY id DESC") or die(mysql_error()); while($rows=mysql_fetch_assoc($getquer… { $id=$rows['id']; $name=$rows['name']; $comment=$rows['comment']; $dellink= "<a href=\"delete.php?id=" . $id . "\"> Delete </a>" ; echo $name . ' ' . ' ' . $comment . ' ' . $dellink . ' '. '<hr width="500px">' ; ;} ?> </body> </html> <?php require("connect.php"); $deleteid=$_GET['id']; mysql_query("DELETE FROM `se211001` WHERE `comment`.`id`='$deleteid']'"); header("location:index.php"); ?>
-
Answer:
>mysql_query("DELETE FROM `se211001` WHERE `comment`.`id`='$deleteid']'"); Are you use this line is correct? In particular what's that ] doing there?
Leah at Yahoo! Answers Visit the source
Other answers
So what is going to make it call delete.php when you are using the backslash for the path in the URL.
Colinc
Related Q & A:
- How to delete Internet address box forever?Best solution by Yahoo! Answers
- A code for a comment box?Best solution by Yahoo! Answers
- Myspace comment box help?
- How do I delete a comment that I made on a video in YouTube?Best solution by ChaCha
- Why are HTML and PHP forms not working?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.