title: php: mysql db connection ok but can't perform query
body: <p>I'm learning php and right now I'm figuring out dbs. Was following up with a tutorial on YT and got stuck in the following:</p>
  
  <p>"retrieve all records from table"</p>
  
  <p>Specifically, I can connect to my DB no prob, but when I perform the select query it prints nothing</p>
  
  <p>Here's my code...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
   //error_reporting(0);
   
   require 'connect.php';
   
   $result = $db-&gt;query("SELECT * FROM sample-objects");
   
   //$result = mysqli_query($db, "SELECT * FROM sample-objects");
   
   print_r($result); 
   
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and my connection script</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
   $db = new mysqli('localhost','root','','test');
   
   // echo $db-&gt;connect_errno,"\n";
   
   if ($db-&gt;connect_errno)
   {
    echo "error: ",$db-&gt;connect_error; /* Imprime descripción de error de DB */
    //die("Site offline");
   }
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I don't get any errors from "connect.php" and I do have 2 records in my db (did so from phpmyadmin)</p>
  
  <p>Any help would be appreciated, thanks :)</p>