我决定使用mysqli而不是mysql而且我有一些错误,这是我第一次使用mysqli,我不知道错误是什么,有什么建议吗?
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/u250000297/public_html/forum/system/db.php on line 45
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/u250000297/public_html/forum/system/db.php on line 45
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/u250000297/public_html/forum/system/db.php on line 45
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/u250000297/public_html/forum/system/db.php on line 45
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /home/u250000297/public_html/forum/system/db.php on line 33
Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/u250000297/public_html/forum/system/db.php on line 33
第32-36行
function query($query) {
$sql = mysqli_query($query, $this->db) or die(mysqli_error());
return $sql;
mysqli_free_result($sql);
}
第44-48行
function fetch($query) {
$sql = mysqli_fetch_array(mysql_query($query, $this->db));
return $sql;
mysqli_free_result($sql);
}
答案 0 :(得分:1)
试试这个,您使用了mysql_query
代替mysqli_query
function query($query) {
$sql = mysqli_query($this->db, $query) or die(mysqli_error());
...
}
function fetch($query) {
mysqli_fetch_array(mysqli_query($this->db, $query));
....
}
而不是
function fetch($query) {
mysqli_fetch_array(mysql_query($query, $this->db));
...
}
答案 1 :(得分:0)
尝试使用像这样的mysqli_query()函数
$data = mysqli_query($dbc, $query);
mysqli_fetch_array($data)
请注意,使用mysqli_query()会传递两个参数:
然后使用mysqli_query()函数的结果作为mysqli_fetch_array()函数的参数:D