I’ve been struggling with this php script for 2 days and cannot figure out why it does not return an id from mysql in the url. Maybe someone could help with this one. I’ve done scripts almost identical to this in the past with success, but this has me stumped. I’m sure it must be something simple that I am missing.
[php]
Delete a Record
'; // Need the database connection: $link = mysql_connect('myDomain, myID, myPassword'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db(myDatabase); if (isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'] > 0) ) { // Display the quote in a form: // Define the query: $query = "SELECT * FROM myTablename WHERE id={$_GET['id']}"; if ($result = mysql_query($query, $link)) { // Run the query. $row = mysql_fetch_array($result); // Retrieve the information. // Make the form: print ' Are you sure you want to delete this Record?' . stripslashes($row['title']) . '
Could not retrieve the Record because:
' . mysql_error($link) . '.
The query being run was: ' . $query . '
'; } } elseif (isset($_POST['id']) && is_numeric($_POST['id']) && ($_POST['id'] > 0) ) { // Handle the form. // Define the query: $query = "DELETE FROM myTablename WHERE id={$_POST['id']} LIMIT 1"; $result = mysql_query($query, $link); // Execute the query. // Report on the result: if (mysql_affected_rows($link) == 1) { print 'The record has been deleted.
'; } else { print 'Could not delete the Record because:
' . mysql_error($link) . '.
The query being run was: ' . $query . '
'; } } else { // No ID received. print 'This page has been accessed in error.
'; } // End of main IF. mysql_close($link); // Close the connection. echo 'Site Admin
'; ?>[/php]