nelamurugan 0 Newbie Poster

Hi,

Am new to here, and i cam here with problem that can be easily solved by you guys, Please help me out.

I have got sqlite3 db dump as dbname.db3,

So then i tried to connect this sqllite from php. Here is my sample code which i got it from forum.

$db = openDatabase();	
	unset($db);

	function openDatabase() {
		$dbFile = realpath('dbname.db3');
		echo $dbFile . "\n";
		$needDbCreate = !file_exists($dbFile);
		$db = new SQLiteDatabase($dbFile) or die((file_exists($dbFile)) ? "Unable to open" : "Unable to create");
		if($needDbCreate) {
			
		}
		return $db;
	}

But i am getting fatal exception.

Fatal error: Uncaught exception 'SQLiteException' with message 'SQLiteDatabase::__construct() [<a href='sqlitedatabase.--construct'>sqlitedatabase.--construct</a>]: file is encrypted or is not a database' in C:\wamp\www\SQLITE\index.php:23 Stack trace: #0 C:\wamp\www\SQLITE\index.php(23): SQLiteDatabase->__construct('C:\wamp\www\SQL...') #1 C:\wamp\www\SQLITE\index.php(15): openDatabase() #2 {main} thrown in C:\wamp\www\SQLITE\index.php on line 23

But when i tried the same sqldump with the PDO , i got connected.

try {
$dbh = new PDO("sqlite:C:\wamp\www\SQLITE\dbname.db3");
echo 'Db Connected <br/>';

}
catch(PDOException $e)
{
echo $e->getMessage();
}

here i do not know the list of tables available in this dump so how can i query them to list and then getting records from them.

Please help me to solve this issue ti get connected and browse the tables from php.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.