无法在NetBeans调试模式下删除记录(使用xDebug)

时间:2013-12-13 01:49:38

标签: php mysql netbeans xdebug

当我使用Netbeans进行调试时,无法执行DELETION,因为 $ test_affected_rows = mysqli_affected_rows($ dbc)将返回-1。这很奇怪,因为我只是运行脚本,删除运行良好。 在调试模式下,mysqli_affected_rows($ dbc)始终返回-1(应为1)。到底是什么原因?

require ('./mysqli_connect.php');

// Check if the form has been submitted:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    if ($_POST['sure'] == 'Yes') { // Delete the record.

        // Make the query:
        $q = "DELETE FROM users WHERE user_id=$id LIMIT 1";     
        $r = @mysqli_query ($dbc, $q);
                 $test_affected_rows= mysqli_affected_rows($dbc);
        if ($test_affected_rows == 1) { // If it ran OK.

            // Print a message:
            echo '<p>The user has been deleted.</p>';   

        } else { // If the query did not run OK.
            echo '<p class="error">The user could not be deleted due to a system error.</p>'; // Public message.
            echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message.
        }

    }
PS.I也尝试在Eclipse PHP中调试,并遇到了同样的问题。所以我猜这可能是一个MySQL问题?

0 个答案:

没有答案