SQLite + Php

General ShopSite user discussion

SQLite + Php

Postby nicolas » Thu Jun 19, 2008 12:00 pm

Hello,

I 'd like to know how to get SKU and Price with PHP 5 and SQLlite from Shopsite ?

Basically, I'd like to give the SKU to the PHP script and that returns the price.

Please advise

Thank You

Nick
nicolas
 
Posts: 12
Joined: Mon Sep 24, 2007 4:02 pm

Postby loren_d_c » Thu Jun 19, 2008 1:38 pm

You should check the SQLite and/or PHP websites for this, for example:

http://us.php.net/sqlite

-Loren
loren_d_c
 
Posts: 2572
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere

Postby nicolas » Thu Jun 19, 2008 3:05 pm

Thank You

I am doing that but I got an exception "file encrypted or not a database"

Here the code:
Code: Select all
$yourfile = "<path-to-db>/shopsite_db";
$database = new SQLiteDatabase($yourfile, 0666, $error);
if (!$database) {
    $error = (file_exists($yourfile)) ? "Impossible to open, check permissions" : "Impossible to create, check permissions";
    die($error);
}
$query = $database->query("SELECT ss_Price FROM ss_Products WHERE ss_SKU = '<MySKU>'", SQLITE_ASSOC, $query_error);
$row = $query->fetch();
print($row['ss_Price']);


Please advise

Nick
nicolas
 
Posts: 12
Joined: Mon Sep 24, 2007 4:02 pm

Postby loren_d_c » Thu Jun 19, 2008 3:35 pm

Sounds like you aren't using a new enough version of PHP or you don't have the right modules loaded, etc. The shopsite_db file is not encrypted, and it IS an SQLite 3 database. Your problem is not a ShopSite problem, but a PHP problem. For example, see:

http://us.php.net/manual/en/ref.sqlite.php#54323

-Loren
loren_d_c
 
Posts: 2572
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere


Return to User Forum

Who is online

Users browsing this forum: No registered users and 76 guests

cron