jukie Posted June 18, 2013 Share Posted June 18, 2013 Hello I'm trying to allow the user to delete a record from a web app. I copied a tutorial on deleting data but struggling to work it out. My php code is <?php include "connection.php";//database connection $order = "SELECT * FROM "members" WHERE Username= '".mysql_real_escape_string($_SESSION['Username'])."' ORDER BY DATE DESC ";; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ echo ("<tr><td>$row[Name]</td>"); echo ("<td>$row[SecondName]</td>"); echo ("<td><a href=\"deletebookmark.php?id=$row[ID]]\">Delete</a></td></tr>"); } ?> The ID in the final row is the id of the record (members) (this could be the issue) deletebookmark.php code <?php include "connection.php"; $order = "DELETE FROM "members" WHERE "" ='$ID'"; mysql_query($order); header("location:member.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/279318-delete-function/ Share on other sites More sharing options...
kicken Posted June 18, 2013 Share Posted June 18, 2013 You need to specify the column name to test against in the WHERE clause. The table name and column name should NOT be quoted. DELETE FROM members WHERE ID=$ID You need to define what $ID is. Based on the code, you want $_GET['id']. You will need to sanitize it to prevent sql injections, using intval will work assuming the id is a number. Quote Link to comment https://forums.phpfreaks.com/topic/279318-delete-function/#findComment-1436665 Share on other sites More sharing options...
jukie Posted June 20, 2013 Author Share Posted June 20, 2013 Tried it with no quoted and still no success. Quote Link to comment https://forums.phpfreaks.com/topic/279318-delete-function/#findComment-1437028 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.