简体   繁体   中英

migrating a Pear DB site to mdb2, syntax error returned

I'm updating a lot of old methods, but I've got stuck with this line

$res =& $mdb2->query($mdb2->prepare("SELECT * FROM book WHERE id = ?"), array($sql_id));

I was getting a message in the error log saying PHP Fatal error: Call to undefined method MDB2_Error::numRows()

So I added this line

if (PEAR::isError($res)) { die($res->getMessage().' ::: '.$res->getUserInfo()); }

to see what was causing the error and I get this back to the screen

MDB2 Error: syntax error ::: _doQuery: [Error message: Could not execute statement] [Last executed query: MDB2 Error: syntax error] [Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MDB2 Error: syntax error' at line 1] 

I'm not sure what's wrong with the query, it looks ok to me?

在这里,无需执行PREPARE部分。

 $res =& $mdb2->query("SELECT * FROM book WHERE id = '" . $sql_id . "' " );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM