title: Notice: Undefined variable: mysqli in... on line 63
body: <p>I received this error I really don't know what to do about it. 
  I'm tyring to build a 'form' with which you can add information to a database. 
  Because I want no double records in my database i'm checking some fields with AJAX.</p>
  
  <p>Here you see the code of my class where I receive my error from. (I use mysqli - language)</p>
  
  <pre><code>&lt;?php
  class Places {
  
      private $m_sName;
      private $m_sStreet;
      private $m_sHouseNumber;
      private $m_sCity;
      private $m_sCategory;
  
      public function __set($p_sProperty, $p_vValue) {
          switch($p_sProperty) {
              case "Name" :
                  $this -&gt; m_sName = $p_vValue;
                  break;
              case "Street" :
                  $this -&gt; m_sStreet = $p_vValue;
                  break;
              case "HouseNumber" :
                  $this -&gt; m_sHouseNumber= $p_vValue;
                  break;
              case "City" :
                  $this -&gt; m_sCity = $p_vValue;
                  break;
              case "Category" :
                  $this -&gt; m_sCategory = $p_vValue;
                  break;
          }
      }
  
      public function __get($p_sProperty) {
          $vResult = null;
          switch($p_sProperty) {
              case "Name" :
                  $vResult = $this -&gt; m_sName;
                  break;
              case "Street" :
                  $vResult = $this -&gt; m_sStreet;
                  break;
              case "HouseNumber" :
                  $vResult = $this -&gt; m_sHouseNumber;
                  break;
              case "City" :
                  $vResult = $this -&gt; m_sCity;
                  break;
              case "Category" :
                  $vResult = $this -&gt; m_sCategory;
                  break;
          }
          return $vResult;
      }
  
      public function addPlaces() 
      {
          include_once("connection.php");
              $sSql = "INSERT INTO tblPlaces
                  (Name, 
                  Street, 
                  HouseNumber, 
                  City, 
                  Category) 
                  VALUES 
                  ('" . $mysqli -&gt; real_escape_string($this -&gt; m_sName) . "', 
                  '" . $mysqli -&gt; real_escape_string($this -&gt; m_sStreet) . "', 
                  '" . $mysqli -&gt; real_escape_string($this -&gt; m_sHouseNumber) . "', 
                  '" . $mysqli -&gt; real_escape_string($this -&gt; m_sCity) . "', 
                  '" . $mysqli -&gt; real_escape_string($this -&gt; m_sCategory) . "')";
  
  
          if (!$mysqli -&gt; query($sSql))
          {
              throw new Exception("Er is iets mis gelopen bij het toevoegen van een plaats");
          }
  
      }
  
      public function placeAvailable()
      {
  
          include("connection.php");
  
          $sSql= "select Street from tblPlaces
                  where Street = '".$this-&gt;m_sStreet."' AND HouseNumber = '".$this-&gt;m_sHouseNumber."'";
  
          $vResult=$mysqli-&gt;query($sSql);
          if($vResult-&gt;num_rows&gt;0)
          {
  
              return(false);  
          }
          else
          {
  
              return(true);
          }
  
          $mysqli-&gt;close();   
      }
  }
  ?&gt;
  </code></pre>
  
  <p>In my connection file I have this code:</p>
  
  <pre><code>&lt;?php
  
  $localhost = "localhost";
  $user = //user hidden
  $password = //paswoord hidden 
  $database = //database hidden
  
  $mysqli = new mysqli($localhost, $user, $password,$database);
  
  if ($mysqli-&gt;connect_error) {
      throw new Exception("Geen Databankconnectie");
  }
  ?&gt;
  </code></pre>
  
  <p>Does anyone have a solution? Or do you also want to see my ajax file and .php page?
  Thanks</p>
  
  <p>EDIT</p>
  
  <p>This is my add.php file (at least everything that matters)</p>
  
  <pre><code>&lt;?php
  $feedback = "";
  include_once ('assets/classes/places.class.php');
  if (isset($_POST['knop'])) {
      try 
      {
          $place1 = new Places;
          $place1 -&gt; Name = $_POST['Name'];
          $place1 -&gt; Street = $_POST['Street'];
          $place1 -&gt; HouseNumber = $_POST['HouseNumber'];
          $place1 -&gt; City = $_POST['City'];
          $place1 -&gt; Category = $_POST['Category'];
  
              if($place1-&gt;placeAvailable())
              {
                  $place1 -&gt; addPlaces();
                  $feedback = $place1 -&gt; Name . ", is met succes toegevoegd!";
              }
              else
              {
                  $feedback = "Sorry";            
              }
      } 
      catch (Exception $e) 
      {
          $feedback = $e -&gt; getMessage();
      }
  }
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
  
          &lt;meta charset="utf-8" /&gt;
          &lt;!-- Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame
          Remove this if you use the .htaccess --&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /&gt;
          &lt;title&gt;Search | FoodSquare&lt;/title&gt;
          &lt;link rel="stylesheet" href="assets/css/reset.css" /&gt;
          &lt;link rel="stylesheet" href="assets/css/style.css" /&gt;
          &lt;script type="text/javascript" src="assets/javascript/geolocation.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
  
          &lt;meta name="description" content="" /&gt;
          &lt;meta name="viewport" content="width=device-width; initial-scale=1.0" /&gt;
          &lt;!-- Replace favicon.ico &amp; apple-touch-icon.png in the root of your domain and delete these references --&gt;
          &lt;link rel="shortcut icon" href="/favicon.ico" /&gt;
          &lt;link rel="apple-touch-icon" href="/apple-touch-icon.png" /&gt;
          &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
              $(document).ready(function(){
              $("#klik").click(function(){
              var naam = $("#naam").val();
              var plaats = $("#straat").val();
              var nummer = $("#huisnummer").val();
              var block = "block";
  
          $.ajax({
              type: "POST",
              url: "assets/ajax/check_place.php",
              data: { eet:naam, place:plaats, number:nummer }
          }).done(function( msg ) {
  
              if(msg.status != "error")
  
                  {
                      if(msg.available == "yes")
                      {
                          $(".feedback").fadeOut();
                      }
                      else
                      {
                          $(".feedback span").text(msg.message);
                          $(".feedback").fadeIn();
                          $(".feedback").css("display", block);
                      }
                  }
  
          });
          return(false);
  
      })
  
  });
  &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  </code></pre>
  
  <p>This is my ajax FILE</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 1);
      include_once('../classes/places.class.php');
  try
  {
      $oPlace = new Places();
      $oPlace-&gt;Name = $_POST['eet'];
      $oPlace-&gt;Street = $_POST['place'];
      $oPlace-&gt;HouseNumber = $_POST['number'];
      if($oPlace-&gt;placeAvailable())
      {
          $feedback['status'] = "success";
          $feedback['available'] = "yes";
          $feedback["message"] = "Go ahead, street is available";
      }   
      else
      {
          $feedback['status'] = "success";
          $feedback['available'] = "no";
          $feedback["message"] ="De zaak " . "'" . $_POST['eet'] . "'". " is reeds op dit adres gevestigd." ;
      }
  }
  catch(exception $e)
  {
      $feedback['status'] = "error";
      $feedback["message"] =$e-&gt;getMessage();
  
  }
  header('Content-type: application/json');
  echo json_encode($feedback);
  ?&gt;
  </code></pre>
  
  <p>Ok guys, I tried several of your solutions but none of them works. I will probably be my fault but I figured something out and i replaced the INCLUDE_ONCE by INCLUDE and now i can add something to my database BUT only without AJAX, when i use AJAX, the form checks if the values are already in the database but when I add them, nothing happens. I also receive no errors. I also receive the right information back from ajax. Can anyone help please? thank you</p>