Teacher, for the paging part, I prompted Warning: mysqli::mysqli(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in E:\yifeng\core\ Db.php on line 19
connect failed:Access denied for user ''@'localhost' (using password: NO)
public static function pagination($table, $where = '' , $page = 1, $pagesize = 10, $order = ''){
$conn = self::db_connect();
$totals = self::totals($table, $where); /Total number of items
$totalpage = ceil($totals / $pagesize); //Total number of pages
$page = max(1, $page); //Current page
$offset = ($ page - 1) * $pagesize; // Starting position of paging query
// Splicing sql
$sql = "select * from {$table}";
if ($where) {
$sql .= " WHERE ".$where;
}
if ($order) {
$sql .= " ORDER BY " . $order;
}
$sql .= " limit ".$offset.','.$pagesize;
$result = $conn->query($sql); // Execute sql
if ($result->num_rows > 0) { // Number of returned data
. # $result->free_result(); // Release result memory
}
$conn->close();
return array(
'total' => $totals,
I called db_connect twice, once directly called db_connect, and the second time called total. I don’t know why the teacher didn’t make an error.
One way is to rewrite it in the paging method to get the total number. The method assigns the value to the variable
跟我的一样的问题
Notice: Undefined variable: db in D:\xuexi\core\db.php on line 18
Notice: Undefined variable: db in D:\xuexi\core\db.php on line 18
Notice: Undefined variable: db in D:\xuexi\core\db.php on line 18
Notice: Undefined variable: db in D:\xuexi\core\db.php on line 18
Warning: mysqli_connect(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in D:\xuexi\core\db.php on line 18
Connection failed:Access denied for user ''@'localhost' (using password: NO)
hesitating
The database password is wrong.