Re: [sqlite] Open sqb database in php?

2006-07-07 Thread C.Peachment
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() . "";
   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:

>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() . "";
>   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: 
>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/>
>>
>> 







Re: [sqlite] Open sqb database in php?

2006-07-07 Thread Albert van Bergen

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:


$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() . "";
  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: 
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/>







Re: [sqlite] Open sqb database in php?

2006-07-06 Thread Firman Wandayandi

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 


Re: [sqlite] Open sqb database in php?

2006-07-06 Thread John Stanton

Both Sqlite V2 and 3 are embedded in the standard PHP release.

Albert van Bergen wrote:

Hi All,

I pretty new into sqlite.

Is it possible to open a sqb database in php?

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

Could be that the database is encrypted (not that I' aware of), but just 
want to make sure if it is possible to open an sqb database.


Albert





Re: [sqlite] Open sqb database in php?

2006-07-06 Thread Stefan de Konink
On Thu, 6 Jul 2006, Albert van Bergen wrote:

> Is it possible to open a sqb database in php?

Natively you can open SQLite 2 databases.


There is a 'package' avaiable to open SQLite 3 database, but I never tried
that.


Stefan



[sqlite] Open sqb database in php?

2006-07-06 Thread Albert van Bergen

Hi All,

I pretty new into sqlite.

Is it possible to open a sqb database in php?

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

Could be that the database is encrypted (not that I' aware of), but just 
want to make sure if it is possible to open an sqb database.


Albert