Results 1 to 2 of 2

Thread: Working with one row in a database

  1. #1
    Join Date
    Jan 2007

    Question Working with one row in a database

    I m trying to print a row from a sqlite3 database but I m getting the error
    Catchable fatal error: Object of class PDOStatement could not be converted to string in /home/ /public_html/test/index.php on line 16

    There is only one row with the counter value so I dont need any fetchall function, is there an way to display and work with one row.

    PHP Code:
    //open the database
    $db = new PDO('sqlite:Counter.db');

    //create the database
    $db->exec("CREATE TABLE Counter (Id INTEGER PRIMARY KEY, Counter INTEGER)");    

    //insert some data...
    $db->exec("INSERT INTO Counter (Counter) VALUES (5000)");

    //now output the data to a simple html table...
    $result $db->query('SELECT * FROM Counter WHERE Id=1');

    // close the database connection
    $db NULL;
    PDOException $e)
    'Exception : '.$e->getMessage();

  2. #2
    Join Date
    Oct 2009
    What code is on line 16?
    Good Luck

    Santos Systems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center