Re: helpt with DB->query() error

From: Date: Mon, 28 Oct 2002 16:40:26 +0000
Subject: Re: helpt with DB->query() error
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2553@lists.php.net to get a copy of this message
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/

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