Reputation: 425
I want to echo onto my screen all the data is my 'userdata' table. i have looked around and found this code but when i run it i get a HTTP ERROR 500. this is my code that im trying to use:
<?php
$database = new SQLite3('home.db');
$result = $database->query("SELECT * FROM userdata");
echo $result;
?>
Upvotes: 0
Views: 1148
Reputation: 2632
the $database->query()
method will return an SQLite3Result
object which you can't just "echo". Instead, you should loop through all the results like so:
<?php
$database = new SQLite3('home.db');
$result = $database->query("SELECT * FROM userdata");
while ($row = $result->fetchArray()) {
print_r($row);
}
?>
The $row
variable inside the while
loop will be an array. Use the appropriate index to get the value of a single column if necessary.
Upvotes: 1