我是编程的初学者。
为什么在函数displayUsers()中未评估$ this->连接?
这是PHP代码:
class T_MySQLDB{
public $connection; //The MySQL database connection
function mysqldb($connection)
{$this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME) or die(mysqli_connect_error());}
function displayUsers()
{
$q = "SELECT username,password "
."FROM ".TBL_USERS." ORDER BY username";
$result = mysqli_query($this->connection, $q);
$num_rows = mysqli_num_rows($result);
return $num_rows;
}
}
/* Create database connection */
$tdatabase = new T_MySQLDB;
echo $tdatabase->displayUsers();