title: Notice: Trying to get property of non-object in C:\xampp\htdocs\php\search.php on line 39
body: <p>I am trying to create search menu in my website, i am using php and mysqli ,i have created all the credential stuffs which are all required to it but still it showing me some errors,can anyone help me from this.
  <strong>analyze.php</strong></p>
  
  
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Gtec NetWork&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;!-- Bootstrap --&gt;
      &lt;link href="asset/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="navbar"&gt;
          &lt;div class="navbar-inner"&gt;
              &lt;a class="brand" href="#"&gt;GTEC Network&lt;/a&gt;
              &lt;ul class="nav"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Boys&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Girls&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="container-fluid"&gt;
          &lt;div class="row"&gt;
              &lt;div class="span12"&gt;
                      &lt;form method="POST" action="search.php"&gt;
                      &lt;label&gt;Search
                              &lt;input type="text" name="keywords" &gt;
                              &lt;input type="submit" class="btn btn-primary lg" value="Search"&gt;
                              &lt;/label&gt;
  
                      &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
    &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p><strong>search.php</strong></p>
  
  <pre><code>&lt;?php  
      require_once 'lib/db.php';
  ?&gt;&lt;?php
      if (isset($_GET['keywords'])) {
          $keywords = $db-&gt;escape_string($_GET['keywords']);
          $query = $db-&gt;query("
              SELECT *
              FROM user 
              WHERE  registernumber LIKE '%{$keywords}%'
              OR username LIKE '%{$keywords}%' 
              "
              );
          $run = mysqli_query($query);
  
      }
  
  ?&gt;
      &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Gtec NetWork&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;!-- Bootstrap --&gt;
      &lt;link href="asset/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="navbar"&gt;
          &lt;div class="navbar-inner"&gt;
              &lt;a class="brand" href="#"&gt;GTEC Network&lt;/a&gt;
              &lt;ul class="nav"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Boys&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Girls&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-4"&gt;
                  Found&lt;?php echo $query-&gt;num_rows;?&gt; results.
                  &lt;?php  
                      if ($query-&gt;num_rows) {
                          while($r = $query-&gt;mysqli_fetch_array())
                          {
                          ?&gt;
  
                          &lt;div class="gylphicon glyphicon-heart"&gt;
                              &lt;a href="#"&gt;&lt;?php echo $r-&gt;username;?&gt;&lt;/a&gt;
                          &lt;/div&gt;
                          &lt;?php   }
                      }?&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem is</p>
  
  <p>Found
  Notice: Undefined variable: query in C:\xampp\htdocs\php\search.php on line 39</p>
  
  <p>Notice: Trying to get property of non-object in C:\xampp\htdocs\php\search.php on line 39
  results. 
  Notice: Undefined variable: query in C:\xampp\htdocs\php\search.php on line 41</p>
  
  <p>Notice: Trying to get property of non-object in C:\xampp\htdocs\php\search.php on line 41</p>
  
  <p>Please help me</p>