You are using PHP syntax incorrectly.
You could use the following:
try {
$dbh = new PDO('sqlite:c:\Program Files\Kinetic\BaseStation\BaseStation.sqb');
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
$Statement = $dbh->prepare("select * from location");
$Statement->execute();
$Array = $Statement->fetchAll(PDO::FETCH_OBJ);
$Statement->closeCursor();
foreach ($Array as $row) {
print_r($row);
On Fri, 7 Jul 2006 16:16:41 +0200, Albert van Bergen wrote:
>Thanks for the info about the PDO_SQLITE. Missed that completly.
>Now I can created an sqlite3 database and read from the database with the
>following code:
><?php
>try {
>$dbh = new PDO('sqlite:c:\Program
>Files\Kinetic\BaseStation\BaseStation.sqb');
> foreach ($dbh->query('SELECT * from location') as $row) {
> print_r($row);
> }
> $dbh = null;
>} catch (PDOException $e) {
> print "Error!: " . $e->getMessage() . "<br/>";
> die();
>}
>?>
>This only works for a database I made.
>The code above gives the following message: " Warning: Invalid argument
>supplied for foreach() in"
>when I try to read a table from the database I want to open.
>The database I want to open can be read with SQLite Admin and the table
>contains data.
>Can someone explain to me why the Warning is coming up?
>Albert
>----- Original Message -----
>From: "Firman Wandayandi" <[EMAIL PROTECTED]>
>To: <[email protected]>
>Sent: Thursday, July 06, 2006 9:37 PM
>Subject: Re: [sqlite] Open sqb database in php?
>> On 7/6/06, Albert van Bergen <[EMAIL PROTECTED]> wrote:
>>> Hi All,
>>>
>>> I pretty new into sqlite.
>>>
>>> Is it possible to open a sqb database in php?
>>>
>>
>> Use PDO_SQLITE for sqlite2 and sqlite3 PHP5 only, or use SQLite
>> extension for sqlite2. SQLite extension already built-in in PHP5, for
>> PHP4 you must load the php_sqlite extension first.
>>
>>> When I use sqlite_open I do get the following warning:
>>>
>>> Warning: sqlite_open() [function.sqlite-open]: file is encrypted or is
>>> not a
>>> database in C:\Program Files\Apache Group\Apache2\htdocs\sql.php on line
>>> 2
>>> file is encrypted or is not a database
>>>
>>
>> I suspect if your file is sqlite database, but it's a sqlite file
>> format version 3 and you tried to open it with sqlite_open() which is
>> support only sqlite file format version3. You should use PDO_SQLITE
>> for open it. Also notes PDO currently support sqlite file format
>> version 3.2, no update yet. So be carefull with your database or your
>> data will lost.
>>
>> --
>> Firman Wandayandi <http://firman.dotgeek.org/>
>>
>>