PDO, sqlite write requests (INSERT) don't working
| From: | KLEIN Stéphane | Date: | Wed, 20 Aug 2008 07:48:02 +0000 |
| Subject: | PDO, sqlite write requests (INSERT) don't working | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-278375@lists.php.net to get a copy of this 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