mardi 17 février 2015

Fetch all values from sqlite DB with PHP

Although I am quite familiar with PHP, I am a newbie in sqlite. I am trying to fetch all values from a Data Table, but I can't get my code to work. After a little research I got this code, but it just doesn't work:



<?php
echo "1";
$dir = "sqlite:/data/Adrian/zusatzstoffe.db";
$dbh = new PDO($dir) or die ("cannot open database");

echo "2";

$stmt = $dbh->prepare("SELECT * FROM zusatzstoffe");
echo "2.5";
$stmt->execute();
$arr = $stmt->fetchArray();

echo "3";

$arr_count = count($arr);
echo $arr_count;
echo "4,";

echo $arr;


My code is running until "2.5". I am using this simple way to find my error, since the server I am using, doesn't show an error log.


Aucun commentaire:

Enregistrer un commentaire