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.
Here's the code:
<?php*
/**This*script*deletes*a*record.**/
print*'<h2>Delete*a*Record</h2>';
//*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*'<form*action="myTablename_delete.php"*method="post">
Are*you*sure*you*want*to*delete*this*Record?
<div><p*class="centerp">'*.*stripslashes($row['title'])*.*'</div>
<input*type="hidden"*FullName="id"*value="'*.*$_GET['id']*.*'"*/>
<input*type="submit"*FullName="submit"*value="Delete*this*Record!"*/>
</form>';
}*else*{*//*Couldn't*get*the*information.
print*'<p*class="error">Could*not*retrieve*the*Record*because:<br*/>'*.*mysql_error($link)*.*'.</p><p>The*query*being*run*was:*'*.*$query*.*'</p>';
}
}*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*'<p*class="centerp">The*record*has*been*deleted.</p>';
}*else*{
print*'<p*class="error">Could*not*delete*the*Record*because:<br*/>'*.*mysql_error($link)*.*'.</p><p>The*query*being*run*was:*'*.*$query*.*'</p>';
}
}*else*{*//*No*ID*received.
print*'<p*class="error">This*page*has*been*accessed*in*error.</p>';
}*//*End*of*main*IF.
mysql_close($link);*//*Close*the*connection.
echo*'<h3>Site*Admin</h3><p*class="centerp"><a*href="myTablename_view.php">View*all*Records</a></p>';*
?>