I have this error and the line was like this:
$stations=$this->$db->query('SELECT * from service_stations');
the $ db variable is declared private, and I use it in the __construct function as follows:
public function __construct() { //after including the config file $host=DB_HOST; $dbname=DB_NAME; $dbuser=DB_USER; $dbpsw=DB_PASSWORD; try{ $pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION; $this->db=new PDO('mysql:host='.$host.';dbname='.$dbname, $dbuser, $dbpsw, $pdo_options); } catch(Exception $e) { die('Erreur: '.$e->getMessage()); } }
thanks in advance:)
source share