[prev in list] [next in list] [prev in thread] [next in thread]
List: pear-general
Subject: Re: [PEAR] helpt with DB->query() error
From: "Sebastian Roebke" <sebastian () sebastian-r ! de>
Date: 2002-10-30 22:21:46
[Download RAW message or body]
Hi Michael,
have you checked the PEAR_Error object using the toString() method instead
of getMessage()?
It may display some more information on the failed query.
Example:
if (DB::isError($result)) {
die($result->toString());
}
HTH,
Sebastian Röbke
----- Original Message -----
From: "Michael Switzer" <mswitzer@choiceoneonline.com>
Newsgroups: php.pear.general
To: <pear-general@lists.php.net>
Sent: Monday, October 28, 2002 5:40 PM
Subject: Re: [PEAR] helpt with DB->query() error
> I'm getting 'DB Error: syntax error'
>
> if I strip the user/pass it says access denied
>
> if I strip the db name, it says 'DB Error: no database selected'
>
> but using the same parameters in the mysql_connect string works fine...
>
> "Jesus M. Castagnetto" <jcastagnetto@yahoo.com> wrote in message
> news:20021025221508.66278.qmail@web12104.mail.yahoo.com...
> > 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/
>
>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic