我收到此错误:
( ! ) 注意:试图在第 18 行的 C:\wamp\www\admin\paginator\Paginator.class.php 中获取非对象的属性。
索引页:
<?php
require_once 'paginator/Paginator.class.php';
$conn = new mysqli( 'localhost', 'USER', 'PASS' );
mysqli_select_db($link, "DB");
$limit = ( isset( $_GET['limit'] ) ) ? $_GET['limit'] : 25;
$page = ( isset( $_GET['page'] ) ) ? $_GET['page'] : 1;
$links = ( isset( $_GET['links'] ) ) ? $_GET['links'] : 7;
$query = "
SELECT utilizatori.id, utilizatori.utilizator, utilizatori.nume, utilizatori.rol_user
AS ID, LOGIN, NUME, ROL
FROM utilizatori
ORDER BY `utilizator` ASC";
$Paginator = new Paginator( $conn, $query );
$results = $Paginator->getData( $page, $limit );
for( $i = 0; $i < count( $results->data ); $i++ ) : ?>
<tr>
<td><?php echo $results->data[$i]['ID']; ?></td>
<td><?php echo $results->data[$i]['NUME']; ?></td>
<td><?php echo $results->data[$i]['LOGIN']; ?></td>
<td><?php echo $results->data[$i]['ROL']; ?></td>
</tr>
<?php endfor; ?>
paginator.class.php:
<?php
class Paginator {
private $_conn;
private $_limit;
private $_page;
private $_query;
private $_total;
public function __construct( $conn, $query ) {
$this->_conn = $conn;
$this->_query = $query;
$rs= $this->_conn->query( $this->_query );
$this->_total = $rs->num_rows;
第 18 行是:
$this->_total = $rs->num_rows;
我检查了所有内容,但无法弄清楚问题出在哪里。谁能比我看到问题出在哪里,好吗?