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:
"retrieve all records from table"
Specifically, I can connect to my DB no prob, but when I perform the select query it prints nothing
Here's my code...
<?php
//error_reporting(0);
require 'connect.php';
$result = $db->query("SELECT * FROM sample-objects");
//$result = mysqli_query($db, "SELECT * FROM sample-objects");
print_r($result);
?>
and my connection script
<?php
$db = new mysqli('localhost','root','','test');
// echo $db->connect_errno,"\n";
if ($db->connect_errno)
{
echo "error: ",$db->connect_error; /* Imprime descripción de error de DB */
//die("Site offline");
}
?>
I don't get any errors from "connect.php" and I do have 2 records in my db (did so from phpmyadmin)
Any help would be appreciated, thanks :)