Results 1 to 6 of 6
Discuss [SQLite] and the iPhones own DB's (PiSA) at the Free Toolchain Software - Hackint0sh.org; I have succesfully installed Apache and PHP on the iPhone. And the SQLite works as ...
  1. #1
    Newbie Array

    Join Date
    Mar 2008
    Posts
    5
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default [SQLite] and the iPhones own DB's (PiSA)

    I have succesfully installed Apache and PHP on the iPhone.
    And the SQLite works as well.

    I can e.g. create a SQLite database.

    But I can't read the DB's that the iPhone creates.

    I have copied (just to make sure) the call_history.db database file to my own directory and chmod 666 (read and write).

    But when I try to connect to the DB doesn't work

    Warning: sqlite_open() [function.sqlite-open]: file is encrypted or is not a database in /Library/WebServer/Documents/callhist/index.php on line 4
    My callhist.php is still fairly simple (to say the least):

    <?

    $db = sqlite_open( "/Library/WebServer/Documents/callhistory/call_history.db");
    $query = "SELECT * FROM call";
    $res = sqlite_query( $db, $query );
    $row = sqlite_fetch_row($res);

    echo $row['address'];


    sqlite_close( $db );

    ?>


  2. #2
    Newbie Array

    Join Date
    Feb 2008
    Posts
    7
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default Owner

    Who is PHP running as? I'll bet it's not the same as the person who owns call_history.db. Try a chown of call_history.db to the same user as PHP. (Make sure you do it to your copy not the original!)

  3. #3
    Newbie Array

    Join Date
    Mar 2008
    Posts
    5
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Quote Originally Posted by meslater View Post
    Who is PHP running as? I'll bet it's not the same as the person who owns call_history.db. Try a chown of call_history.db to the same user as PHP. (Make sure you do it to your copy not the original!)
    When I have CHMODed the file (666) everyone can read.

    But my Apache/PHP runs as nobody. I have tried CHOWN the db file to nobody, - but that didn't change anything.

    The php file is by the way still owned by root (and that reads fine)

    -rw-rw-rw- 1 nobody admin 12288 Mar 9 00:48 call_history.db
    -rw-r--r-- 1 root admin 252 Mar 9 01:17 index.php

  4. #4
    Senior Professional Array

    Join Date
    Mar 2008
    Posts
    120
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    12

    Default

    Are you sure, that the database you created is compatible with the sqlite version php is linked with? The "file is encrypted or is not a database" happens if you try to open a sqlite3 database with sqlite2 (php is still linked with the old version).

  5. #5
    Newbie Array

    Join Date
    Mar 2008
    Posts
    5
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Quote Originally Posted by mikrohard View Post
    Are you sure, that the database you created is compatible with the sqlite version php is linked with? The "file is encrypted or is not a database" happens if you try to open a sqlite3 database with sqlite2 (php is still linked with the old version).
    Of course thats it (I didn't know, - thank you).

    But how do I link PHP with sqlite3? I can see sqlite3 is in Cydia. But just installing it isn't enough, is it?
    Last edited by DaDane; 03-11-2008 at 01:56 AM.


  6. #6
    Newbie Array

    Join Date
    Mar 2008
    Posts
    2
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    As mikrohard said, it doesn't work with sqlite3 directly from PHP, so you have to use exec() to get it to work.

    First install sqlite3 in cydia, then try this:

    <?php

    exec('sqlite3 /Library/WebServer/Documents/callhistory/call_history.db "SELECT address FROM call"',$result);

    foreach ($result as $v)
    {
    echo $v . '<br />';
    }

    ?>

    I didn't test it, but I think it should work. You might need to chmod some stuff to 755, not sure.

 

 

Similar Threads

  1. Open Notes.db sqlite DB from iPhoneSDK
    By mentor667 in forum iPhone Developer Exchange
    Replies: 12
    Last Post: 11-28-2011, 09:39 PM
  2. sqlite db in bundle
    By sjurmr in forum iPhone Developer Exchange
    Replies: 1
    Last Post: 12-11-2008, 11:55 AM
  3. APP REQUEST : SQLite .DB Editor
    By ugene in forum Free Toolchain Software
    Replies: 0
    Last Post: 10-24-2007, 06:23 AM
  4. PHP + Sqlite
    By fabiopigi in forum Free Toolchain Software
    Replies: 0
    Last Post: 10-13-2007, 11:52 AM
  5. SQLite access in iPhone?
    By RVN84 in forum Free Toolchain Software
    Replies: 0
    Last Post: 08-22-2007, 11:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 11:19 AM.
twitter, follow us!