Thread: PHP and SQLite

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    PHP and SQLite


    In the following code I keep getting a blank webpage. My /var/log/apache2/error.log file is showing this

    -> [Fri Aug 30 10:20:50 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

    I have installed SQLite, PECL, & PDO. Any ideas? I'm at a loss.

    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>";
    ?>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    What version of PHP are you using? From 5.4 on that extension is only available in PECL. Have you installed that?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    862
    Rep Power
    275
    why are you posting this AGAIN? Why not continue with your other thread and answer the questions from it?.....then, maybe we can continue to try to help you.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    PHP Version 5.4.9-4ubuntu2.2


    I'm using PHP Version 5.4.9-4ubuntu2.2. I checked out synaptic package manager and did a search for PECL, I installed php-pear, dh-make-php & php-auth.

    Originally Posted by gw1500se
    What version of PHP are you using? From 5.4 on that extension is only available in PECL. Have you installed that?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    Post the output of phpinfo.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    here's the info


    Originally Posted by gw1500se
    Post the output of phpinfo.
    Here it is below, I hope this isn't s security risk.

    phpinfo()
    PHP Version => 5.4.9-4ubuntu2.2

    System => Linux bedroom 3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013 x86_64
    Build Date => Jul 15 2013 18:22:08
    Server API => Command Line Interface
    Virtual Directory Support => disabled
    Configuration File (php.ini) Path => /etc/php5/cli
    Loaded Configuration File => /etc/php5/cli/php.ini
    Scan this dir for additional .ini files => /etc/php5/cli/conf.d
    Additional .ini files parsed => /etc/php5/cli/conf.d/10-pdo.ini,
    /etc/php5/cli/conf.d/20-pdo_sqlite.ini,
    /etc/php5/cli/conf.d/20-sqlite3.ini

    PHP API => 20100412
    PHP Extension => 20100525
    Zend Extension => 220100525
    Zend Extension Build => API220100525,NTS
    PHP Extension Build => API20100525,NTS
    Debug Build => no
    Thread Safety => disabled
    Zend Signal Handling => disabled
    Zend Memory Manager => enabled
    Zend Multibyte Support => provided by mbstring
    IPv6 Support => enabled
    DTrace Support => disabled

    Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
    Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls
    Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies


    _______________________________________________________________________


    Configuration

    bcmath

    BCMath support => enabled

    Directive => Local Value => Master Value
    bcmath.scale => 0 => 0

    bz2

    BZip2 Support => Enabled
    Stream Wrapper support => compress.bzip2://
    Stream Filter support => bzip2.decompress, bzip2.compress
    BZip2 Version => 1.0.6, 6-Sept-2010

    calendar

    Calendar support => enabled

    Core

    PHP Version => 5.4.9-4ubuntu2.2

    Directive => Local Value => Master Value
    allow_url_fopen => On => On
    allow_url_include => Off => Off
    always_populate_raw_post_data => Off => Off
    arg_separator.input => & => &
    arg_separator.output => & => &
    asp_tags => Off => Off
    auto_append_file => no value => no value
    auto_globals_jit => On => On
    auto_prepend_file => no value => no value
    browscap => no value => no value
    default_charset => no value => no value
    default_mimetype => text/html => text/html
    disable_classes => no value => no value
    disable_functions => no value => no value
    display_errors => Off => Off
    display_startup_errors => Off => Off
    doc_root => no value => no value
    docref_ext => no value => no value
    docref_root => no value => no value
    enable_dl => Off => Off
    enable_post_data_reading => On => On
    error_append_string => no value => no value
    error_log => no value => no value
    error_prepend_string => no value => no value
    error_reporting => 22527 => 22527
    exit_on_timeout => Off => Off
    expose_php => On => On
    extension_dir => /usr/lib/php5/20100525 => /usr/lib/php5/20100525
    file_uploads => On => On
    highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
    highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
    highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
    highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
    highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
    html_errors => Off => Off
    ignore_repeated_errors => Off => Off
    ignore_repeated_source => Off => Off
    ignore_user_abort => Off => Off
    implicit_flush => On => On
    include_path => .:/usr/share/php:/usr/share/pear => .:/usr/share/php:/usr/share/pear
    log_errors => On => On
    log_errors_max_len => 1024 => 1024
    mail.add_x_header => On => On
    mail.force_extra_parameters => no value => no value
    mail.log => no value => no value
    max_execution_time => 0 => 0
    max_file_uploads => 20 => 20
    max_input_nesting_level => 64 => 64
    max_input_time => -1 => -1
    max_input_vars => 1000 => 1000
    memory_limit => -1 => -1
    open_basedir => no value => no value
    output_buffering => 0 => 0
    output_handler => no value => no value
    post_max_size => 8M => 8M
    precision => 14 => 14
    realpath_cache_size => 16K => 16K
    realpath_cache_ttl => 120 => 120
    register_argc_argv => On => On
    report_memleaks => On => On
    report_zend_debug => Off => Off
    request_order => GP => GP
    sendmail_from => no value => no value
    sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
    serialize_precision => 17 => 17
    short_open_tag => On => On
    SMTP => localhost => localhost
    smtp_port => 25 => 25
    sql.safe_mode => Off => Off
    track_errors => Off => Off
    unserialize_callback_func => no value => no value
    upload_max_filesize => 2M => 2M
    upload_tmp_dir => no value => no value
    user_dir => no value => no value
    user_ini.cache_ttl => 300 => 300
    user_ini.filename => .user.ini => .user.ini
    variables_order => GPCS => GPCS
    xmlrpc_error_number => 0 => 0
    xmlrpc_errors => Off => Off
    zend.detect_unicode => On => On
    zend.enable_gc => On => On
    zend.multibyte => Off => Off
    zend.script_encoding => no value => no value

    ctype

    ctype functions => enabled

    date

    date/time support => enabled
    "Olson" Timezone Database Version => 0.system
    Timezone Database => internal
    Default timezone => America/Chicago

    Directive => Local Value => Master Value
    date.default_latitude => 31.7667 => 31.7667
    date.default_longitude => 35.2333 => 35.2333
    date.sunrise_zenith => 90.583333 => 90.583333
    date.sunset_zenith => 90.583333 => 90.583333
    date.timezone => no value => no value

    dba

    DBA support => enabled
    Supported handlers => cdb cdb_make db4 inifile flatfile

    Directive => Local Value => Master Value
    dba.default_handler => flatfile => flatfile

    dom

    DOM/XML => enabled
    DOM/XML API Version => 20031129
    libxml Version => 2.9.0
    HTML Support => enabled
    XPath Support => enabled
    XPointer Support => enabled
    Schema Support => enabled
    RelaxNG Support => enabled

    ereg

    Regex Library => Bundled library enabled

    exif

    EXIF Support => enabled
    EXIF Version => 1.4 $Id$
    Supported EXIF Version => 0220
    Supported filetypes => JPEG,TIFF

    Directive => Local Value => Master Value
    exif.decode_jis_intel => JIS => JIS
    exif.decode_jis_motorola => JIS => JIS
    exif.decode_unicode_intel => UCS-2LE => UCS-2LE
    exif.decode_unicode_motorola => UCS-2BE => UCS-2BE
    exif.encode_jis => no value => no value
    exif.encode_unicode => ISO-8859-15 => ISO-8859-15

    fileinfo

    fileinfo support => enabled
    version => 1.0.5

    filter

    Input Validation and Filtering => enabled
    removed

    Directive => Local Value => Master Value
    filter.default => unsafe_raw => unsafe_raw
    filter.default_flags => no value => no value

    ftp

    FTP support => enabled

    gettext

    GetText Support => enabled

    hash

    hash support => enabled
    removed

    iconv

    iconv support => enabled
    iconv implementation => glibc
    iconv library version => 2.17

    Directive => Local Value => Master Value
    iconv.input_encoding => ISO-8859-1 => ISO-8859-1
    iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
    iconv.output_encoding => ISO-8859-1 => ISO-8859-1

    json

    json support => enabled
    json version => 1.2.1

    libxml

    libXML support => active
    libXML Compiled Version => 2.9.0
    libXML Loaded Version => 20900
    libXML streams => enabled

    mbstring

    Multibyte Support => enabled
    Multibyte string engine => libmbfl
    HTTP input encoding translation => disabled
    libmbfl version => 1.3.2

    mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

    Multibyte (japanese) regex support => enabled
    Multibyte regex (oniguruma) backtrack check => On
    Multibyte regex (oniguruma) version => 4.7.1

    Directive => Local Value => Master Value
    mbstring.detect_order => no value => no value
    mbstring.encoding_translation => Off => Off
    mbstring.func_overload => 0 => 0
    mbstring.http_input => pass => pass
    mbstring.http_output => pass => pass
    mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
    mbstring.internal_encoding => no value => no value
    mbstring.language => neutral => neutral
    mbstring.strict_detection => Off => Off
    mbstring.substitute_character => no value => no value

    mhash

    MHASH support => Enabled
    MHASH API Version => Emulated Support

    openssl

    OpenSSL support => enabled
    OpenSSL Library Version => OpenSSL 1.0.1c 10 May 2012
    OpenSSL Header Version => OpenSSL 1.0.1c 10 May 2012

    pcntl

    pcntl support => enabled

    pcre

    PCRE (Perl Compatible Regular Expressions) Support => enabled
    PCRE Library Version => 8.31 2012-07-06

    Directive => Local Value => Master Value
    pcre.backtrack_limit => 1000000 => 1000000
    pcre.recursion_limit => 100000 => 100000

    PDO

    PDO support => enabled
    PDO drivers => sqlite

    pdo_sqlite

    PDO Driver for SQLite 3.x => enabled
    SQLite Library => 3.7.15.2

    Phar

    Phar: PHP Archive support => enabled
    Phar EXT version => 2.0.1
    Phar API version => 1.1.1
    SVN revision => $Id: removed
    Phar-based phar archives => enabled
    Tar-based phar archives => enabled
    ZIP-based phar archives => enabled
    gzip compression => enabled
    bzip2 compression => enabled
    Native OpenSSL support => enabled


    Phar based on pear/PHP_Archive, original concept by Davey Shafik.
    Phar fully realized by Gregory Beaver and Marcus Boerger.
    Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
    Directive => Local Value => Master Value
    phar.cache_list => no value => no value
    phar.readonly => On => On
    phar.require_hash => On => On

    posix

    Revision => $Id: removed

    readline

    Readline Support => enabled
    Readline library => EditLine wrapper

    Directive => Local Value => Master Value
    cli.pager => no value => no value
    cli.prompt => \b \> => \b \>

    Reflection

    Reflection => enabled
    Version => removed

    session

    Session Support => enabled
    Registered save handlers => files user
    Registered serializer handlers => php php_binary wddx

    Directive => Local Value => Master Value
    session.auto_start => Off => Off
    session.cache_expire => 180 => 180
    session.cache_limiter => nocache => nocache
    session.cookie_domain => no value => no value
    session.cookie_httponly => Off => Off
    session.cookie_lifetime => 0 => 0
    session.cookie_path => / => /
    session.cookie_secure => Off => Off
    session.entropy_file => /dev/urandom => /dev/urandom
    session.entropy_length => 32 => 32
    session.gc_divisor => 1000 => 1000
    session.gc_maxlifetime => 1440 => 1440
    session.gc_probability => 0 => 0
    session.hash_bits_per_character => 5 => 5
    session.hash_function => 0 => 0
    session.name => PHPSESSID => PHPSESSID
    session.referer_check => no value => no value
    session.save_handler => files => files
    session.save_path => /var/lib/php5 => /var/lib/php5
    session.serialize_handler => php => php
    session.upload_progress.cleanup => On => On
    session.upload_progress.enabled => On => On
    session.upload_progress.freq => 1% => 1%
    session.upload_progress.min_freq => 1 => 1
    session.upload_progress.name => removed
    session.upload_progress.prefix => removed
    session.use_cookies => On => On
    session.use_only_cookies => On => On
    session.use_trans_sid => 0 => 0

    shmop

    shmop support => enabled

    SimpleXML

    Simplexml support => enabled
    Revision => removed
    Schema support => enabled

    soap

    Soap Client => enabled
    Soap Server => enabled

    Directive => Local Value => Master Value
    soap.wsdl_cache => 1 => 1
    soap.wsdl_cache_dir => /tmp => /tmp
    soap.wsdl_cache_enabled => 1 => 1
    soap.wsdl_cache_limit => 5 => 5
    soap.wsdl_cache_ttl => 86400 => 86400

    sockets

    Sockets Support => enabled

    SPL

    SPL support => enabled
    removed

    sqlite3

    SQLite3 support => enabled
    SQLite3 module version => 0.7
    SQLite Library => 3.7.15.2

    Directive => Local Value => Master Value
    sqlite3.extension_dir => no value => no value

    standard

    Dynamic Library Support => enabled
    Path to sendmail => /usr/sbin/sendmail -t -i

    Directive => Local Value => Master Value
    assert.active => 1 => 1
    assert.bail => 0 => 0
    assert.callback => no value => no value
    assert.quiet_eval => 0 => 0
    assert.warning => 1 => 1
    auto_detect_line_endings => 0 => 0
    default_socket_timeout => 60 => 60
    from => no value => no value
    url_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame=src,input=src,form=fakeentry
    user_agent => no value => no value

    sysvmsg

    sysvmsg support => enabled
    Revision => $Id: removed

    tokenizer

    Tokenizer Support => enabled

    wddx

    WDDX Support => enabled
    WDDX Session Serializer => enabled

    xml

    XML Support => active
    XML Namespace Support => active
    libxml2 Version => 2.9.0

    xmlreader

    XMLReader => enabled

    xmlwriter

    XMLWriter => enabled

    zip

    Zip => enabled
    Extension Version => $Id: removed
    Zip version => 1.11.0
    Libzip version => 0.10.1

    zlib

    ZLib Support => enabled
    Stream Wrapper => compress.zlib://
    Stream Filter => zlib.inflate, zlib.deflate
    Compiled Version => 1.2.1.1
    Linked Version => 1.2.7

    Directive => Local Value => Master Value
    zlib.output_compression => Off => Off
    zlib.output_compression_level => -1 => -1
    zlib.output_handler => no value => no value

    Additional Modules

    Module Name
    sysvsem
    sysvshm

    Environment

    Variable => Value
    SSH_AGENT_PID => 2048
    GPG_AGENT_INFO => removed
    TERM => xterm
    SHELL => /bin/bash
    XDG_SESSION_COOKIE => removed
    GJS_DEBUG_OUTPUT => stderr
    WINDOWID => 44040197
    GNOME_KEYRING_CONTROL => removed
    GJS_DEBUG_TOPICS => JS ERROR;JS LOG
    USER => garrett
    SSH_AUTH_SOCK => removed
    SESSION_MANAGER => removed
    USERNAME => garrett
    DEFAULTS_PATH => /usr/share/gconf/default.default.path
    XDG_CONFIG_DIRS => /etc/xdg/xdg-default:/etc/xdg
    PATH => removed
    DESKTOP_SESSION => default
    PWD => /home/garrett
    GNOME_KEYRING_PID => 1956
    LANG => en_US.UTF-8
    MANDATORY_PATH => /usr/share/gconf/default.mandatory.path
    MDM_XSERVER_LOCATION => local
    CINNAMON_VERSION => 1.8.8
    SHLVL => 1
    HOME => /home/garrett
    GNOME_DESKTOP_SESSION_ID => this-is-deprecated
    LOGNAME => garrett
    XDG_DATA_DIRS => removed
    DBUS_SESSION_BUS_ADDRESS => removed
    MDMSESSION => default
    TEXTDOMAIN => im-config
    WINDOWPATH => 8
    XDG_RUNTIME_DIR => removed
    DISPLAY => :0
    MDM_LANG => en_US.UTF-8
    XDG_CURRENT_DESKTOP => GNOME
    GARRETT => removed
    TEXTDOMAINDIR => /usr/share/locale/
    COLORTERM => gnome-terminal
    XAUTHORITY => /tmp/.mdmPSCZ2W
    _ => /usr/bin/php5

    PHP Variables

    Variable => Value
    _SERVER["SSH_AGENT_PID"] => removed
    _SERVER["GPG_AGENT_INFO"] => removed
    _SERVER["TERM"] => xterm
    _SERVER["SHELL"] => /bin/bash
    _SERVER["XDG_SESSION_COOKIE"] => removed
    _SERVER["GJS_DEBUG_OUTPUT"] => stderr
    _SERVER["WINDOWID"] => 44040197
    _SERVER["GNOME_KEYRING_CONTROL"] => removed
    _SERVER["GJS_DEBUG_TOPICS"] => JS ERROR;JS LOG
    _SERVER["USER"] => garrett
    _SERVER["SSH_AUTH_SOCK"] => removed
    _SERVER["SESSION_MANAGER"] => removed
    _SERVER["USERNAME"] => garrett
    _SERVER["DEFAULTS_PATH"] => /usr/share/gconf/default.default.path
    _SERVER["XDG_CONFIG_DIRS"] => /etc/xdg/xdg-default:/etc/xdg
    _SERVER["PATH"] => removed
    _SERVER["DESKTOP_SESSION"] => default
    _SERVER["PWD"] => /home/garrett
    _SERVER["GNOME_KEYRING_PID"] => removed
    _SERVER["LANG"] => en_US.UTF-8
    _SERVER["MANDATORY_PATH"] => /usr/share/gconf/default.mandatory.path
    _SERVER["MDM_XSERVER_LOCATION"] => local
    _SERVER["CINNAMON_VERSION"] => 1.8.8
    _SERVER["SHLVL"] => 1
    _SERVER["HOME"] => /home/garrett
    _SERVER["GNOME_DESKTOP_SESSION_ID"] => this-is-deprecated
    _SERVER["LOGNAME"] => garrett
    _SERVER["XDG_DATA_DIRS"] => removed
    _SERVER["DBUS_SESSION_BUS_ADDRESS"] => removed
    _SERVER["MDMSESSION"] => default
    _SERVER["TEXTDOMAIN"] => im-config
    _SERVER["WINDOWPATH"] => 8
    _SERVER["XDG_RUNTIME_DIR"] => removed
    _SERVER["DISPLAY"] => :0
    _SERVER["MDM_LANG"] => en_US.UTF-8
    _SERVER["XDG_CURRENT_DESKTOP"] => GNOME
    _SERVER["GARRETT"] => Garrett Gaston
    _SERVER["TEXTDOMAINDIR"] => /usr/share/locale/
    _SERVER["COLORTERM"] => gnome-terminal
    _SERVER["XAUTHORITY"] => /tmp/.mdmPSCZ2W
    _SERVER["_"] => /usr/bin/php5
    _SERVER["PHP_SELF"] => removed
    _SERVER["SCRIPT_NAME"] => removed
    _SERVER["SCRIPT_FILENAME"] => removed
    _SERVER["PATH_TRANSLATED"] => removed
    _SERVER["DOCUMENT_ROOT"] =>
    _SERVER["REQUEST_TIME_FLOAT"] => 1377961802.7415
    _SERVER["REQUEST_TIME"] => 1377961802
    _SERVER["argv"] => Array
    (
    [0] => /var/www/removed
    )

    _SERVER["argc"] => 1

    PHP License
    This program is free software; you can redistribute it and/or modify
    it under the terms of the PHP License as published by the PHP Group
    and included in the distribution in the file: LICENSE

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    If you did not receive a copy of the PHP license, or have any
    questions about PHP licensing, please contact license@php.net.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    862
    Rep Power
    275
    IMHO, I think your easiest fix is to convert your sqlite(2) database to a sqlite3 database and use OOP to access your sqlite3 DB.

    Assuming you have both sqlite and sqlite3 installed, using terminal, the conversion is as easy as
    Code:
    sqlite /path/to/your/oldsqlite-dbfile .dump > backupfile
    
    sqlite3 /path/to/your/newsqlite3-dbfile < backupfile

    then, to access it in php
    PHP Code:
    $db = new SQLite3('./path/to/newsqlite3-dbfile',SQLITE3_OPEN_READWRITE);
    if(!
    $db){
    echo 
    "could not open/access DB";
    }else{
    //do what you wanted to do with the DB

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9
    [QUOTE=DonR]IMHO, I think your easiest fix is to convert your sqlite(2) database to a sqlite3 database and use OOP to access your sqlite3 DB.

    Code:
    sqlite /path/to/your/oldsqlite-dbfile .dump > backupfile
    
    sqlite3 /path/to/your/newsqlite3-dbfile < backupfile
    The fist line worked -> sqlite /path/to/your/oldsqlite-dbfile .dump > backupfile but when I ran the second line I got this ->

    Error: near line 2: file is encrypted or is not a database
    Error: near line 3: file is encrypted or is not a database

    Any ideas?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    You have the sqlite PDO drivers. Use PDO, not only is it easier, you can easily port your code to different database engines rather than being locked in to sql3.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    862
    Rep Power
    275
    Originally Posted by gw1500se
    You have the sqlite PDO drivers. Use PDO, not only is it easier, you can easily port your code to different database engines rather than being locked in to sql3.
    I was under the impression that the PDO_SQLITE extension in PHP5.4 only worked with sqlite3 DBs.


    Originally Posted by Garrett85
    The fist line worked -> sqlite /path/to/your/oldsqlite-dbfile .dump > backupfile but when I ran the second line I got this ->

    Error: near line 2: file is encrypted or is not a database
    Error: near line 3: file is encrypted or is not a database

    Any ideas?
    What are the exact commands you used?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    Originally Posted by DonR
    I was under the impression that the PDO_SQLITE extension in PHP5.4 only worked with sqlite3 DBs.
    The PDO sqlite 2 driver is also available for legacy databases however it does not have all the features of 3. The good news is that it is trivial, from the PHP perspective, to upgrade to 3 later. That is one of the benefits of PDO.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    Mostly fixed


    Okay, I couldn't get SQLite3 to recieve the DB from SQLite but by database is so small, just three columns that I wen ahead and created a new DB in SQLite3. My problem now is that the $result variable isn't displaying on the webpage. When I run select * from customers; in SQLite3 it displays one entry with three columns, but in my PHP code it doesn't display anything. Note that it is displaying "Database is here"
    PHP Code:
    <?php
    echo "<html>";
    echo 
    "<body>";

    $db = new SQLite3('./et.sqlite3'SQLITE3_OPEN_READWRITE);

    if(!
    $db)
    {
            echo 
    "Could not open/access DB";
    }
    else
    {
            echo 
    "Database is here";
            
    $result $db->query('select * from customers');
            echo 
    "$result";
    }

    echo 
    "</body>";
    echo 
    "</html>";
    ?>
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    862
    Rep Power
    275
    like this:
    PHP Code:
    {
            echo 
    "Database is here";
            
    $result $db->query('select * from customers');
            echo 
    "<table border='1'>";
                     while(
    $row $result->fetchArray(SQLITE3_ASSOC)){
                            echo 
    "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";
                     } 
    echo 
    "</table>";

    I think thats correct.
    Last edited by DonR; August 31st, 2013 at 05:47 PM.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    $result is an object not a scalar. You should use var_dump to display its contents for debugging purposes. However, it will not be very helpful. You need to fetch, using one of the functions, the returned rows then process them to get any useful output.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    58
    Rep Power
    9

    Almost there!


    So here's where I'm at now. I've got the script displaying all three columns of the only row in the DB but I don't like the way it's displaying. Here's what it's giving me ->

    string(7) "FirstName" Array ( [fname] => Firstname [lname] => LastName [email] => myEmailAddress )

    This is to technical for what I'm wanting, I simply want it to display in the browser as "FirstName LastName EmailAddress" without all the => signs.

    Here's my code as it currently stands.

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

    $db = new SQLite3('./et.sqlite3'SQLITE3_OPEN_READWRITE);

    if(!
    $db)
    {
        echo 
    "Could not open/access DB";
    }
    else
    {
        echo 
    "Database is here";
        
    //$result = $db->query('select * from customers');
        //var_dump($db->querySingle('select * from customers'));
        //print_r($db->querySingle('select * from customers', true));
        
    $result $db->querySingle('select * from customers');
        
    //echo $result;
        
    $query sqlite_query($db'select * from customers');
        while(
    $entry sqlite_fetch_array($querySQLITE_NUM))
        {
            echo 
    $entry[0]." ".echo $entry[1]." ". echo $entry[2];
        }

        
    $i 0;

        while(
    $i strlen($result))
        {
            echo 
    $result[$i];
            
    $i++;
        }
    }

    echo 
    "</body>";
    echo 
    "</html>";
    ?>
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo