Re: helpt with DB->query() error

From: Date: Wed, 30 Oct 2002 22:21:46 +0000
Subject: Re: helpt with DB->query() error
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2571@lists.php.net to get a copy of this message
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/ > >

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