Re: helpt with DB->query() error
| From: | Jesus M. Castagnetto | Date: | Fri, 25 Oct 2002 22:15:08 +0000 |
| Subject: | Re: helpt with DB->query() error | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2546@lists.php.net to get a copy of this message | ||
Michael,
My guess is that $connection_string is undefined in the scope of the function.
If it is a global, use $GLOBALS['connection_string'] instead.
What might be happening is that you are getting back a PEAR_Error object no a
database connection one. Use PEAR::isError() always for error handling, e.g.:
if (PEAR::isError($db)) {
// handle error
} else {
$result = $db->query($sql);
if (PEAR::isError($result)) {
// do something
} else {
// keep on trucking ;-)
}
}
--- Michael Switzer <mswitzer@choiceoneonline.com> wrote:
> After form submittal I call -
> $online = Account::login($_POST['un'],$_POST['pw']);
>
> I receive an error
>
> Fatal error: Call to undefined function: query()
>
> pointing to this code, specifically the line highlighted below
>
> class Account {
>
> function login($username,$password) {
> $db = DB::connect($connection_string);
> $sql = "select * from $acctTblName where $acctUsrFld='$username' AND
> $acctPwdFld='$password'";
>
> //------- the line below -----------
> $result = $db->query($sql);
>
> Anyone have ideas on why this isn't working?
=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
Research:
http://metallo.scripps.edu/
Personal: http://www.castagnetto.org/
__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/