警告:mysqli_close()恰好需要1个参数,其中0个给定 [英] Warning: mysqli_close() expects exactly 1 parameter, 0 given in
本文介绍了警告:mysqli_close()恰好需要1个参数,其中0个给定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直收到下面列出的以下错误,我想知道如何纠正此错误.
I keep getting the following error listed below and I was wondering how do I correct this error.
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');
?>
推荐答案
错误消息很明显:您调用了mysqli_close
,没有任何参数,而函数需要一个参数.
The error message is clear : you called mysqli_close
without any argument, while the function expects one.
根据mysqli_close
文档,必须提供mysqli链接作为其参数.
According to mysqli_close
documentation, you must provide the mysqli link as its argument.
这篇关于警告:mysqli_close()恰好需要1个参数,其中0个给定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文