$ mysqli = new mysqli(“localhost”,“root”,“”,“test”); $ mysqli-> query('PREPARE mid FROM“SELECT name FROM test_user WHERE id =?”'); //工作代码开始 // $ res = $ mysqli-> query('PREPARE mid FROM FROM SELECT name FROM test_user''); // $ res = $ mysqli-> query('EXECUTE mid;')or die(mysqli_error($ mysqli)); //工作代码结束.. $ res = $ mysqli-> query('EXECUTE mid 1;')or die(mysqli_error($ mysqli));mysqli准备声明错误?
while($resu = $res->fetch_object()) {
echo '<br>' .$resu->name;
}
错误:
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 '1' at line 1
我的php版本是PHP Version 5.3.0
和MySQL
mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $
我使用where clause
我该怎么称呼这个多次? – Linto 2010-05-18 20:25:39
这里的想法是,您准备查询,绑定值,执行准备好的查询,绑定其他值,再次使用这些新值执行准备好的查询等。因此,只需再次调用execute()即可。更多信息:http://www.php.net/manual/en/mysqli-stmt.execute.php – Alec 2010-05-18 20:33:38