Web Hosting Talk







View Full Version : PHP PDO help...


That Guy
04-27-2008, 09:07 PM
I'm having some problems with PDO. Here's my code:

$db = new PDO('sqlite:main.db');
$db->exec("insert into stuff (name) values ('asfasdf');");

I don't get any errors, but the value isn't being inserted into the database. What am I doing wrong?

huwnet
04-28-2008, 01:46 PM
Try:

$query = $db->exec("insert into stuff (name) values ('asfasdf');");

Then echo'ing $query should give you an error

That Guy
04-28-2008, 02:22 PM
Tried it, didn't work. :(

Paul
04-28-2008, 02:53 PM
$db->exec("insert into stuff (name) values ('asfasdf')") or die($db->errorInfo());

That Guy
04-28-2008, 10:15 PM
When I run it, it says "Array"

Dark Light
04-29-2008, 05:11 AM
To dump the contents of the array, try using this instead:


die(var_dump($db->errorInfo()));


Hope that helps,