Lorenzo Lorenzo - 2 years ago 92
PHP Question

Database path on raspberry

I'm new in raspberry and I'm trying to read a simple database from a php page but there is something wrong: I can't read the database content: Here the php page code:

<!DOCTYPE html>
<H1>Test Database</H1>


$sq = sqlite_open('miodatabase.db', 0666, $sqlite_error);

die(“Errore Sqlite: “.$sqlite_error);

$result = sqlite_query($sq, 'select * from test');
while($data = sqlite_fetch_array($result))
echo $data[‘nome’];


The database is "miodatabase" that contains a table called "test". I put the database in \var\www\html folder (is correct?) but when I open the page I see a blank page. I'm sure the database contains the table (tested with sqlite3 commands) and the table contains one row. Where I need to put the database? Why I can't see nothing? Thanks

Answer Source

If you don't see anything, i think it's a php configuration issue.

Did you try to add :

  <?php  phpinfo(); ?>

at the beginning of your script. If you have blank page, look your apache/nginx configuration.

You can also try to run your script from the command line. Maybe helpful in some case.


If you use SQLite3 follow this code

class MyDB extends SQLite3
    function __construct()

$db = new MyDB();
$result = $db->query('select * from test', SQLITE3_OPEN_READWRITE );

while($data = $result->fetchArray())
   echo $data[‘nome’];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download