当谈到使用 php 编程时,我是一个初学者。目前我正在一个带有数据库的项目中工作。当我尝试调用我的查询时出现问题:$r = mysqli_query($db, $q);
我收到此错误:
这是我连接到数据库的课程:
class conectDB{
var $dbUser;
var $dbPassword;
var $dbHost;
var $dbName;
function __construct() {
$this->dbUser ='root';
$this->dbPassword = '';
$this->dbHost = 'localhost';
$this->dbName = 'db';
$dbc = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName) or die('Fatal error!');
}
}
在这里我调用我的查询:
$db = new conectDB();
$q='SELECT * FROM categories ORDER BY category';
$r = mysqli_query($db, $q);
while(list($id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)){
echo '<li><a href="category.php?id='.$id.'" title="'.$category.'">'.$category.'</a></li>';
}