|
Posted by Jerry Stuckle on 11/15/06 20:38
loudwinston@gmail.com wrote:
> Hello,
>
> I'm encountering a strange error with PDO. The server is FreeBSD 4.4,
> PHP 5.1.2, mySQL 4.0.20 with 4.1.18 client libs.
>
> I have the following code (usernames and passwords changed to protected
> the innocent ^_^)
>
> <?
> $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"
>
> What's strange is this code works fine on my development servers, and
> used to work fine on this server up until a few days ago. I've
> restarted the server several times, recompiled php with the following
> configure script
>
> ./configure --with-pdo-mysql=/usr/local/mysql --with-curl=/usr/local
> --enable-versioning --enable-memory-limit --with-layout=GNU
> --enable-ctype --enable-overload --enable-posix --enable-session
> --enable-tokenizer --with-expat-dir=/usr/local --with-imap=/usr/local
> --with-jpeg-dir=/usr/local --with-mysql=/usr/local/mysql
> --with-pcre-regex=yes --with-png-dir=/usr/local --with-zlib-dir=/usr
> --with-zlib=yes --with-regex=php --enable-cli
> --with-apxs2=/usr/local/www/bin/apxs --prefix=/usr/local
> i386--freebsd4.4 --enable-spl --with-pdo --enable-pdo
> --with-gd=/usr/local --disable-all
>
> This is the only script that gets run so there's definitely no problems
> with open cursors (I've read the posts about
> PDOStatement::closeCursor()).
>
> The only thing I can think of is that the 4.1.18 mySQL client libs wont
> work with PDO and mySQL 4.0.20. I've tested with old-school mysql
> functions (mysql_connect) and it works fine, its only PDO that breaks.
>
> Does anyone have any idea? Thanks so much for any help.
>
> ~Kevin
>
Kevin,
It looks like your prepare call has a problem.
You should always check the return value. If falls, call
db->errorInfo() and display your error message. It should help you find
your problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|