Php 对布尔错误调用成员函数fetch_array()
我收到这个错误,有人能帮我解决吗Php 对布尔错误调用成员函数fetch_array(),php,Php,我收到这个错误,有人能帮我解决吗 Fatal error: Call to a member function fetch_array() on boolean in /Applications/XAMPP/xamppfiles/htdocs/RECORD BREAKERS/includes/connection.php on line 33 这是密码 require_once("connection.php"); class genre { private $sGenreName;
Fatal error: Call to a member function fetch_array() on boolean in /Applications/XAMPP/xamppfiles/htdocs/RECORD BREAKERS/includes/connection.php on line 33
这是密码
require_once("connection.php");
class genre
{
private $sGenreName;
private $iGenreID;
public function __construct()
{
$this->sGenreName=" ";
$this->iGenreID=0;
}
public function getGenre($sGenreID)
{
//make coonection
$oConnection = new Connection();
//create query
$sSQL = "SELECT GenreName,GenreID from tbgenres where GenreID=2";
//execute
$oResultSet=$oConnection->query($sSQL);
//fetch data
$aRow=$oConnection->fetchArray($oResultSet);
$aRow=$oConnection->fetchArray($oResultSet);
$this->sGenreName=$aRow["GenreName"];
$this->sGenreName=$aRow["GenreID"];
}
public function __get($var)
{
switch ($var) {
case 'GenreName':
return $this->sGenreName;
break;
case 'GenreID':
return $this->sGenreID;
break;
}
}
}
$g=new genre();
$g->getGenre(2);
echo $g;
?>
$aRow=$oConnection->fetchArray($oResultSet)代码>它被写了两次。请删除。右@AG21->一旦获取数据,就不能重新获取。如果您想要重新获取,那么使用mysqli_data_seek($aRow,0);您使用SQLite3吗?如果没有,请显示用于建立数据库连接的API的相关代码。$aRow=$oConnection->fetchArray($oResultSet)代码>它被写了两次。请删除。右@AG21->一旦获取数据,就不能重新获取。如果您想要重新获取,那么使用mysqli_data_seek($aRow,0);您使用SQLite3吗?如果没有,请显示与数据库连接的API的相关代码。