PHP警告有帮助吗?

saw*_*awu 0 php mysqli

我一直收到下面列出的以下错误,我想知道如何更正此错误.

Warning: mysqli_close() expects exactly 1 parameter, 0 given in
Run Code Online (Sandbox Code Playgroud)

这是下面列出的代码.

<?php
require_once ('./mysqli_connect.php'); // Connect to the db.

function make_list ($parent) {

    global $tasks;

    echo '<ol>';

    foreach ($parent as $task_id => $todo) {

        echo "<li>$todo";

        if (isset($tasks[$task_id])) { 

            make_list($tasks[$task_id]);

        }

        echo '</li>';

    } // End of FOREACH loop.

    // Close the ordered list:
    echo '</ol>';

} // End of make_list() function.

    $mysqli = new mysqli("localhost", "root", "", "sitename");
    $dbc = mysqli_query($mysqli,"SELECT task_id, parent_id, task FROM tasks WHERE date_completed='0000-00-00 00:00:00' ORDER BY parent_id, date_added ASC");
if (!$dbc) {
    // There was an error...do something about it here...
    print mysqli_error();
} 

$tasks = array();

while (list($task_id, $parent_id, $task) = mysqli_fetch_array($dbc, MYSQLI_NUM)) {

    // Add to the array:
    $tasks[$parent_id][$task_id] =  $task;

}

make_list($tasks[0]);


mysqli_close(); // close the connection

// Include the html footer
include('./includes/footer.html');
?>
Run Code Online (Sandbox Code Playgroud)

Syl*_*ain 6

错误消息很明确:你没有任何参数调用mysqli_close,而函数需要一个.

根据mysqli_close文档,您必须提供mysqli链接作为其参数.