我不斷收到下面列出的以下錯誤,我在想如何糾正這個錯誤。PHP警告幫助?
Warning: mysqli_close() expects exactly 1 parameter, 0 given in
以下是下面列出的代碼。
<?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');
?>
我該怎麼辦呢? – sawu 2009-10-31 17:12:47
當您連接到數據庫時,您會得到一個表示與數據庫的連接的對象。 使用過程方式,它可能如下所示: $ link = mysqli_connect(「localhost」,「user」,「passwd」,「db」); mysqli_close($ link); OO方式可能如下所示: $ mysqli = new mysqli(「localhost」,「user」,「passwd」,「db」); 和 $ mysqli-> close(); – Sylvain 2009-10-31 17:20:06