Re: error checking for databases - Fatal error: Call to undefined function
| From: | Pierre-Alain Joye | Date: | Mon, 05 Aug 2002 00:04:06 +0000 |
| Subject: | Re: error checking for databases - Fatal error: Call to undefined function | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2050@lists.php.net to get a copy of this message | ||
On Sun, 4 Aug 2002 16:51:50 -0700
<jeff@altahost.com> wrote:
ted at the botom of this email generates this error message:
>
> Fatal error: Call to undefined function: fetchrow()
>
> When the SQL is written for a valid table the code works fine. Why does it
> generate **this** error message when the SQL has an error?
The result is not a resultset, it s an error. So you have to use the db error object (which do not
have a fetchrow method :) ).
Btw, add these lines in your code.
> require_once( 'DB.php' );
>
> $db = DB::connect( "mysql://$user:$password@$host/$database" );
> $sql = 'SELECT * FROM BogusTable';
> $demoResult = $db->query($sql);
if(!DB::isError($demoResult)){
> while ($demoRow = $demoResult->fetchRow())
> {
> echo $demoRow[0] . '<br>';
> }
>
> if (DB::isError($demoResult))
> {
> die ($demoResult->getMessage());
> }
} else {
echo $demoResult->getMessage();
}
> $db->disconnect();
>
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php