title: fetching error in mysqli [Trying to get property of non-object]
body: <p>I am trying to solve something out. this time I am using mysqli and not PDO. </p>
  
  <p>The problem: I am getting an error saying: "Notice: Trying to get property of non-object in ..." 
  I only get that problem when I put the LIKE or " = " statement in the sql query, when I remove it, it is good. </p>
  
  <p>What I am trying to do: Basically, I am saying if the option in the dropdown is selected, then get some info about the agencies in that specific city location only.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if(isset($_POST["submit"])){
  
      $elpost = $_POST["cityName"];
      $sql = "SELECT office_name, office_location, office_phone FROM `easyt_findagents_agents WHERE office_city='$elpost";
      $result = $db-&gt;query($sql);
  
      //Display states list
      if ($result-&gt;num_rows &gt; 0) {
          // output data of each row
          while($row = $result-&gt;fetch_assoc()) {
              echo $row['office_name'];
          }
      } else {
  
          echo "0 results";
      }
  }
  </code></pre>
  
  <p>any thoughts on how to fix that? I've searched a lot but didn't find anything why this is happening.</p>
  
  <p>Thanks in advance for everybody.</p>