Hello this sound easy but something seems to be wrong here,
include_once('class.DBconnnection.php');//connects to DB and works fine
class execute extends db
{
private $sqlString;
private $selected;
private $querySelected;
public function select($sqlString)
{
$connection=$this->getConnection();
$querySelected=$connection->query($sqlString);
if($querySelected->num_rows>0){
$this->Fetch();
}
else{
echo'No Data Available';
}
}
public function Fetch(){
return $querySelected->fetch_array();
}
}
on implimenting the above class
try{
$connect=db::getInstance();
$conn=$connect->getConnection();
$execute=new execute();
$execute->select('select * from users limit 5');
while($execute->Fetch()){
echo $row['username'].'<br/>';
}
}
catch(Exception $e){
echo $e->getMessage();
}
on running i recieve the error: Fatal error: Call to a member function fetch_array() on a non-object in C:\wamp\www\PHP5_Testing\classes\class.execute.php on line 20
can anyone help me to fix this problem? when i used procedural mysqli it worked fine but the problem is now with oop mysqli