1
<?php

    if (intval($_GET['page']) == 0) {
        redirect_to("staff.php");
    }

    $id = mysqli_prep($_GET['page']);



        $query3 = "DELETE FROM page WHERE id = {$id}, LIMIT 1";
        $result = mysqli_query($connection, $query3);
        if (mysqli_affected_rows($connection) == 1) {
            redirect_to("staff.php");
        } else {
            // Deletion Failed

            echo $id ."<br />" . $query3 . "<br />" . $result . "<p>Subject
           deletion failed.</p>";
            echo "<p>" . mysqli_error() . "</p>";
            echo "<a href=\"staff.php\">Return to Main Page</a>";
        }
      //  Keep on working Edit:2#
      mysqli_query($connection, "DELETE FROM pages WHERE id = 11 ");
     //- Works 
     Edit 3# 
       $id = $_GET['page'];
        echo "<p>" . $id ."</p>";
            $query3 ="DELETE FROM pages WHERE id = {$id} ";
                    mysqli_query($connection,$query3 );
                    // Still Works  -- YaY for working backwards
   // Edit #4 By "now it might be obvious what my error was "pages" not "page"
       // Thanks everyone - And thank you for telling me about the error page
        // My defense - newbie- Anyway Lesson from this - working backwards 
        // Takes a while, Error checking Fast!!!!!!
?>

$connection 已启动并被选中。$id选择成功,$page=$id,但是还是不行。$query 3 看起来不错,但删除失败。我不知道错误是什么。感谢您提前提供任何帮助。-Josh 编辑检查错误检查

4

4 回答 4

1

ID后面有一个逗号:

$query3 = "DELETE FROM page WHERE id = {$id}, LIMIT 1";
                                            ^ remove this
于 2013-03-12T17:15:52.797 回答
0

我不知道错误是什么。

那是因为你没有检查。每次准备或执行查询时,都需要检查错误。FALSE如果遇到错误,mysqli 中的大多数函数都会返回。

$result = mysqli_query($connection, $query3);
if ($result === false) {
    trigger_error(mysqli_error($connection), E_USER_ERROR);
    header("Location: /error.php");
    exit;
}

未能检查错误案例是数据库程序员最常犯的错误之一。

于 2013-03-12T17:46:53.173 回答
0
  if ($page == get_page_by_id($id)) {

== 比较

=== 比较值和演员表

$val = true;
if ($val === true) {
    echo "\$val is bool(true)";
}

if ($val == "true") {
    echo "\$val matches value";
}


if ($val === "true") {
// this will never happen
} else {
echo "\$val doesnt === \"true\"";
}
于 2013-03-12T17:12:37.403 回答
-1

尝试php_flag display_errors on在您的 .htaccess 中使用这将允许您查看和识别 php 错误。

于 2013-03-12T18:00:43.787 回答