Hello,
I have a strange problem with PEAR DB class. I use PHP with PEAR on a
Windows XP machine and I use MySQL as database.
The following code doesn't realy work as i expect it to:
// Use the standard DSN
$dsn = getDSN();
// Connect to the databse and check for errors
$db = DB::connect($dsn,true);
if (DB::isError($db)) {
echo "Could not connect!";
die ( $db->getMessage() );
}
// All we have tod do is to select a few columns from the person
table
$sql = "SELECT personID, firstname, surname, title FROM `person`
WHERE personId>0 ORDER BY surname";
$psql = $db->quote($sql);
// Get the data with getAll
$result = $db->query($psql);
if (DB::isError($result)) {
echo "<p>DSN: $dsn";
echo "<p>Query failed</p>";
echo "<p>".$result->getUserInfo()."</p>";
die ($result->getMessage());
} else {
....
It fails after the query with the following error:
**************
DSN: mysql://xxx:yyy@localhost/persondatabas
Query failed
'SELECT personID, firstname, surname, title FROM `person` WHERE personId>0
ORDER BY surname' [nativecode=1064 ** You have an error in your SQL syntax
near ''SELECT personID, firstname, surname, title FROM `person` WHERE
personId>0 ORDER' at line 1]
DB Error: syntax error
***************
The SQL works in phpMyAdmin. The problem might be realy easy but i don't
see it. Could some one please help me?
--
Henrik Karlsson | www.henriks.org
Studying Automation Engineering | ICQ: UIN 2785561
at Chalmers University of Technology | +46-707-99 50 31
"Coughlin's law - anything else is always something better."
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|