Sorry not working... i changed: <?php class DataBase { private $con; private $host; private $user; private $password; private $dataBase; private $queryString; private $result; private $row; function __construct() { $this->host = 'localhost'; $this->user = 'root'; $this->password = ''; $this->dataBase = 'importtable'; $this->con = new mysqli($this->host, $this->user, $this->password, $this->dataBase); } function connectionString() { if ($this->con->error) { echo "Sikertelen adatbázis kapcsolódás"; die(); } } function selectUser($query){ $this->queryString=mysqli_real_escape_string($this->con,$query); $this->result=$this->con->query($this->queryString); $this->row=$this->result->fetch_assoc(); echo $this->row['id']; } } class showUser extends DataBase { private $userId; function __construct($id) { $this->userId = $id; } function showData() { if(filter_var($this->userId)){ $q = "select * from user where id=" . $this->userId; $this->selectUser($q); } else{ } } } $o= new showUser(1); $o->showData(); ?>
now i have this messages:
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\import_\dbconn.php on line 32 Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\import_\dbconn.php on line 33