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:<?php
try
{
//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');
echo $result;
// close the database connection
$db = NULL;
}
catch(PDOException $e)
{
print 'Exception : '.$e->getMessage();
}
?>


Reply With Quote
Bookmarks