get id from mysql database

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]

<?php /* This script deletes a record. */ print '

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']) . '

'; } else { // Couldn't get the information. print '

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

View all Records

'; ?>

[/php]

Without seeing the table structure it’s hard to say if this is correct or not.

Your mysql_connect looks wrong, I’m not sure if you did that just to paste it here.

Also, on your form:

FullName="id"
FullName="submit"

FullName should be “name”

name="id"
name="submit"
Sponsor our Newsletter | Privacy Policy | Terms of Service