#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    Connecting to SQLite


    Linux System. In the following code when if I uncomment a single reference to SQLite nothing on the page will load, it's completly blank. Is there something in the code that is wrong or do I need to turn on SQLite in a php configure script. If so, where is this script and what's the option I need to look for? Also, if you have the line number that would be great.

    PHP Code:
    <?php
    echo "<html>";
    echo 
    "<body>?";
    // get variable from html form
    $fName $_POST['fname'];
    $lName $_POST['lname'];
    $address $_POST['email'];

    $db sqlite_open('./et'0666"$error_message")

    //if($db == sqlite_open('./et'))
    {
    //$result = sqlite_query($db, 'select * from customers');
    //echo $result;
    }
    echo 
    "hello world!";
    echo 
    "</body>";
    echo 
    "</html>";
    ?>
    Okay, so I just added the ';' to the end of the sqlite_open line and now the page is shows a '?' in the top left corner. Any ideas?
    Last edited by Garrett85; August 23rd, 2013 at 10:21 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,508
    Rep Power
    594
    When you see a blank page it means there was a fatal error in your script. You need to look at the httpd log to see what the error is. The '?' you are seeing is from the one right after the <body> tag. When you commented out the 'if' block you left dangling '{}' characters.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,549
    Rep Power
    2337
    php Code:
    $db = sqlite_open('./et', 0666, "$error_message")


    You're missing something important at the end of this line.

    Comments on this post

    • gw1500se disagrees : The last sentence indicates the OP saw that error and fixed it.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    /var/log/apache2/error.log


    I've pretty much commented out everything but the sqlite_open line and I'm getting this error in the log file.

    [Sun Aug 25 15:55:14 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function sqlite_open() in /var/www/ET/process.php on line 9


    Any ideas?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    do you have the sqlite php modules installed/enabled?
    you can check by doing a phpinfo() and looking for the sqlite section.

    If you don't see it, you will have to install it using your pkg manager.( in Debian it would be sudo apt-get install php5-sqlite)
    Last edited by DonR; August 25th, 2013 at 04:29 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    Thanks, but


    Thanks but I'm still getting a completly white page after running sudo apt-get install php5-sqlite. But after running that command I now see sqlite setting from my phpinfo script so I do believe there was some progress with your suggestion, although I'm still stuck. Since running that command I now see the heading "PDO" with two columns, PDO support with the value PDO drivers, & enabled with the value sqlite. The other heading I see is pdo_sqlite with two columns as well. PDO Driver for SQLite 3.x wtih the value SQLite Library, & enabled with the value 3.7.15.2. And the heading sqlite3 with two columns, SQLite3 support wtith the values SQLite3 module version, & SQLite Library, and the column enabled with the values 0.7 & 3.7.15.2. Below is my code as it currently stands, still getting a white page and this error -> Call to undefined function sqlite_open() in /var/www/ET/process.php on line 9

    PHP Code:
    <?php
    echo "<html>";
    echo 
    "<body>";
    // get variable from html form
    //$fName = $_POST['fname'];
    //$lName = $_POST['lname'];
    //$address = $_POST['email'];

    $db sqlite_open('./et'0666"$error_message");


    //if($db == sqlite_open('./et'))
    //{
    //$result = sqlite_query($db, 'select * from customers');
    //echo $result;
    //}
    echo "hello world!";
    echo 
    "</body>";
    echo 
    "</html>";
    ?>
    Originally Posted by DonR
    do you have the sqlite php modules installed/enabled?
    you can check by doing a phpinfo() and looking for the sqlite section.

    If you don't see it, you will have to install it using your pkg manager.( in Debian it would be sudo apt-get install php5-sqlite)
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    you will probably need to install sqlite and/or sqlite3 (depending on which version you are working with in your DB), also.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    sqlite


    I have already made an sqlite DB and the file is in the same directory as the the php file. Hence be using sqlite_open('./et'); the database is named 'et'. Yet I still get unknown function sqlite_open?

    Originally Posted by DonR
    you will probably need to install sqlite and/or sqlite3 (depending on which version you are working with in your DB), also.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    Did you restart Apache Web Server after installing those sqlite modules?
    Are you sure your sqlite db is a sqlite version 2 DB and not a version 3 DB?

    If its a version 3 DB, then you will have to use different syntax.

    See if this gives you error:
    PHP Code:
    $db = new SQLite3('./et'SQLITE_OPEN_READONLY); 

IMN logo majestic logo threadwatch logo seochat tools logo