Posted by Michael Fesser on 11/15/06 19:38
..oO(loudwinston@gmail.com)
><?
>$db_dsn = "mysql:host=dbHost;dbname=dbName";
>$db_username = "username";
>$db_password = "password";
>$db = new PDO($db_dsn, $db_username, $db_password);
>$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
>$statement = $db->prepare("SELECT * FROM myTable");
>$statement->execute();
>?>
>
>I get an error on the last line "Fatal error: Call to a member function
>execute() on a non-object"
There's no error handling.
PDO::prepare() returns FALSE if something goes wrong.
Then check PDO::errorInfo() to get more informations.
Micha
[Back to original message]
|