Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP classes misunderstandings
    primarykey
    data
    text
    <p>I'm trying to make a CMS and I'm stuck using classes in PHP.</p> <p>I have this little connection class and I don't know why it's not working. It's giving me the this error:</p> <blockquote> <p>Notice: Undefined variable: mysqli in C:\Users\eha\Desktop\Carlos' Stuff\xampp\htdocs\test\layout\system\class.php on line 4</p> <p>Fatal error: Cannot access empty property in C:\Users\eha\Desktop\Carlos' Stuff\xampp\htdocs\test\layout\system\class.php on line 4</p> </blockquote> <pre><code>class server_connect { function __construct($host, $user, $password, $database) { $this-&gt;$mysqli = new mysqli($host, $user, $password, $database); if ($mysqli-&gt;connect_error) { die('Connect Error (' . $mysqli-&gt;connect_errno . ') ' . $mysqli-&gt;connect_error); } } protected $mysqli = NULL; protected function set_connection(&amp;$serverconnect){ $this-&gt;$mysqli = $serverconnect; } } class site_manager extends server_connect { </code></pre> <p>ok now I get the syntax for that now when calling a parent element $mysqli Im doing parent::$mysqli and its telling me that its a undeclared variable</p> <pre><code>class site_manager extends server_connect { function __construct(&amp;$conect){ parent::set_connection($conect); } public function getContent($page , $sub){ if($page == 'home' || ($page != 'home' &amp;&amp; $sub ==NULL)) $qry = "SELECT * FROM public WHERE section = ?"; else $qry = "SELECT * FROM public WHERE section = ? AND subsection = ?"; $stmt = parent::$mysqli-&gt;stmt_init(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload