ja_blackburn Posted November 28, 2009 Share Posted November 28, 2009 This is nearly working but im missing something. I have printed out a DB table into HTML on the page and have a link to the ID to delete a record. It is refreshing but not actually deleting? SEND PAGE: <?php include'E:\domains\s\domain.com\user\private\mysql_connect.php'; mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM mailing_list"); echo "<table border='1'> <tr> <th>ID</th> <th>Name</th> <th>Email Address</th> <th>Interest</th> <th>Country</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['interest'] . "</td>"; echo "<td>" . $row['country'] . "</td>"; echo "<td>" .'<a href="delete_mail.php?id='.$row['ID'].'">Delete</a>'. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> DELETE method: <? // Connect database. include'E:\domains\s\domain\user\private\mysql_connect.php'; // Get values from form. $id=$_GET['ID']; // Do delete statement. mysql_query("delete from mailing_list where ID='$id'"); // Close database connection mysql_close(); // Redirect header("location:view_mailing_list.php"); ?> What am I missing?! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/ Share on other sites More sharing options...
abazoskib Posted November 28, 2009 Share Posted November 28, 2009 i'm pretty sure its case sensitive, so try // Get values from form. $id=$_GET['id']; if that doesnt work, echo mysql_error() after mysql_query() Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/#findComment-966993 Share on other sites More sharing options...
PFMaBiSmAd Posted November 28, 2009 Share Posted November 28, 2009 You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you. (Confirm the actual settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using.) You will save a ton of time. There would have been an undefined index error message in your code concerning $_GET['ID'] that would have alerted you to the fact that is not being set because it does not match the ?id being put on the end of the URL. Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/#findComment-966995 Share on other sites More sharing options...
ja_blackburn Posted November 28, 2009 Author Share Posted November 28, 2009 Im getting this error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 16 does not like something about this line: header("location:view_mailing_list.php"); bear with me, i am learning php. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/#findComment-967000 Share on other sites More sharing options...
abazoskib Posted November 28, 2009 Share Posted November 28, 2009 i copy pasted what you have above, and i didnt get that error. Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/#findComment-967004 Share on other sites More sharing options...
ja_blackburn Posted November 28, 2009 Author Share Posted November 28, 2009 Thanks I have it working now. Quote Link to comment https://forums.phpfreaks.com/topic/183223-delete-record-using-id-from-database/#findComment-967006 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.