title: Undefined variable: mysqli - PHP OOP
body: <p>How can I implement mysqli in an extended class?</p>
  
  <p>I am uploading an image and storing it in a MySQL database, but I get this error:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: mysqli in ...ecc/ecc/ on line 33</p>
    
    <p>Fatal error: Call to a member function query() on a non-object in ...ecc/ecc/ on line 33</p>
  </blockquote>
  
  <p>Here is my test code:</p>
  
  <pre><code>&lt;?php
      interface ICheckImage {
          public function checkImage();
          public function sendImage();
      }           
      abstract class ACheckImage implements ICheckImage {
          public $image;
          private $mysqli;    
          public function _construct(){
              $this-&gt;image = $_POST['image'];
              $this-&gt;mysqli = new mysqli('localhost','test','test','test');
          }
      }           
      class Check extends ACheckImage {
          public function checkImage() {
              if($this-&gt;image &gt; 102400) {
                  echo "File troppo grande";
              } 
          }
          public function sendImage() {
              //This is the line 33 give me the error
              if ($mysqli-&gt;query("INSERT INTO images (image) VALUES ('$this-&gt;image')")) {
              echo "Upload avvenuto &amp;nbsp";
              } else {
                  echo "Errore &amp;nbsp" . $mysqli-&gt;error;
              }  
          }
      }   
      $form = new Check();
      $form-&gt;checkImage();    
      $form-&gt;sendImage();
  ?&gt;
  </code></pre>