[thelist] Newbie PEAR DB quoting question

Faust at LeeMarvin.com Faust at LeeMarvin.com
Thu Feb 28 09:24:30 CST 2002


Hi,

I'm new to PEAR DB and can't figure out how to get DB::quote() to work.
I've tried

$username = $dbh->quote($username); \\ Don't work
$password = DB::quote($password);       \\ Don't work either

and neither way works.  Here is a sample function:

function login($username, $password) {
 include_once ('DB.php');
 $dbh = DB::connect($GLOBALS['dsn'], true);
 if ($dbh->isError())) {
  echo "Error message: " . $dbh->getMessage()  . "<br>\n"
         . $dbh->getDebugInfo() . "<br>\n";
 }
 $username = $dbh->quote($username);
 $password = DB::quote($password);
 $sql = "SELECT * FROM user
                             WHERE username = '$username' and
                                            password = password('$password')";
 $result = $dbh->query($sql);
 if (DB::isError($result)) {
  echo "Error message: " . $dbh->getMessage()  . "<br>\n"
         . $dbh->getDebugInfo() . "<br>\n";
 }
 return ($result->numRows() > 0);
}

What am I doing wrong?


TIA

Faust
Maraschino:
 delicious cherry derivative, fermented and distilled, then
 flavored by the bruised cherry stones themselves.
 Maraschino is so essential that no fairly equipped bar can
 afford to be without it.
-- from Charles Baker's _The Gentleman's Companion_





More information about the thelist mailing list