Re: DB error checking, returns error when query works?

From: Date: Wed, 01 Oct 2003 21:57:00 +0000
Subject: Re: DB error checking, returns error when query works?
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8211@lists.php.net to get a copy of this message
On Wednesday 01 October 2003 16:55, Keith Pettit wrote: > Just gave it a try and I get the same error as I did with fetchRow. > > Fatal error: Call to a member function on a non-object in > /srv/www/etc/functions.php on line 103 > > And it no longer updates the database. > > This is the code I'm using: > > $result = $dbh->query($query); > if(!DB::isError($result)) { > die($result->getMessage()); > } else { > print "It worked!"; > } > $dbh->disconnect(); > > I'm using this in a funtion if that matters at all. That might matter. It's quite likely that $dbh is not known in the function as a database resource. > > > Keith > > Pierre-Alain Joye wrote: > >On Wed, 01 Oct 2003 15:27:52 -0600 > > > >Keith Pettit <keith@setuplinux.com> wrote: > >>This is my first time using pear DB and it seems to be working. > >> I'm doing some update statements which work, but the error > >> checking is still showing errors. > >> > >>Here is what I'm doing... > >> > >> $query = "UPDATE test set ......"; > >> > >> $result = $dbh->query($query); > >> if(!DB::isError($result)) { > >> print "ERROR: $result \n"; > >> } else { > >> print "It worked!"; > >> } > > > >it should be: > > > >if(DB::isError($result)) { > > die($result->getMessage();); <=== only for this example :) > >} else { > > print "It worked!"; > >} > > > >pierre -- James 'Chip' Kaufman jkaufman@wamnetgov.com 651-256-5137 PGP key: 697D43DE

« previous php.pear.general (#8211) next »