我在 all 旁边列出了一个 Delete 链接$rows
,当我将鼠标悬停在它们上时,它们反映了正确的删除 ID,但是,当我单击时,DELETE
我被重定向到phpfile.php?id=4
,例如,没有任何内容被删除,也没有发布错误。
while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC))
{
echo '<tr><td align="left">' .
$row['title'] . '</td><td align="left">'
. $row['genre'] . '</td><td align="left">'
. $row['length'] . '</td><td align="left">'
. $row['created'] . '</td><td align="left">'
. $row['views'] . '</td><td align="left">'
. "<a href='newwriter_profile.php?id={$row['upload_id']}'>Delete</a></td>" . '</tr>';
}
echo '</table>'; // Close the table
代码的其余部分,存在于同一页面上:
if(isset($_GET['id'])) {
// Get the ID
$id = intval($_GET['upload_id']);
require_once ('../mysqli_connect.php'); //Connect to the db
$delquery = "
DELETE
FROM upload
WHERE upload_id = {$id}";
$done = @mysqli_query ($dbc, $delquery); // Run the query
if($done) {
// Make sure the result is valid
if (mysqli_num_rows($done)==1) {
echo 'Record Deleted';
}
else {
echo 'error - delete failed';
}
// Free the mysqli resources
@mysqli_free_result($result);
}
else {
echo "Error! Query failed:" .$mysqli_error($dbc);
}
mysqli_free_result($done);
mysqli_close($dbc);
}
如果我能解决这个错误,我会解决一个类似的错误,除了下载功能。