Re: PDO, sqlite write requests (INSERT) don't working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi KLEIN, I think the problem is where you are connecting to your database. I've not used SQL lite before, but the function spec says that you have too many arguments. It suggests connecting like this:

if ($db = new SQLiteDatabase('filename'))

Also, do you need to specify the sqlite: protocol before the path? Does the system even know what this path is? One further note; you are using a relative path, but is it relative to the right location? Does it have to be relative to the system runtime or the PHP file? Try an absolute path to see if that fixes it.

Ash
www.ashleysheridan.co.uk
--- Begin Message ---
Hi,

it's the first time I use sqlite in PHP script.

All read requests work perfectly but I don't get on execute write 
requests.

Example :

<?php
try { $dbh = new PDO("sqlite:../example1.sqlite", '', ''); }
catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); }

var_dump($dbh);

$firstname = "foobarbbar";
$lastname = "barbarbar";

try {
    $sql = "INSERT INTO contact (firstname, lastname) VALUES('".addslashes($firstname)."', '".addslashes($lastname)."')";
    $result = $dbh->exec($sql);
    var_dump($result);
} catch(PDOExecption $e) { 
    print "Error!: " . $e->getMessage() . "</br>"; 
}
?>

$ ls ../ -lha
...
-rw-rw-rw- 1 stephane stephane 237K 2008-08-19 21:09 example1.sqlite
...

When I launch this script INSERT request don't work, nothing is inserted in contact table.

var_dump($result) return : bool(false)

Have you already see this issue ? What is my mistake ?

Thanks for your help,
Stephane



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux