Problem with multiple prepared statements

牧云@^-^@ 提交于 2019-12-02 03:01:12

Note that the mysqli extension has been replaced by PDO, which is simpler to use and better behaved. You should use it rather than mysqli. If you need a PDO tutorial, try "Writing MySQL Scripts with PHP and PDO". Even if you switch, you may still wish to figure out what is going wrong, in which case read on.

That particular error simply means you're not dealing with a mysqli_stmt in $select_something or $select_something_else. Functions in many extensions (especially DB extensions) return false when they fail, rather than a resource or object. That's probably what's happening here. Follow proper error handling procedure by testing the return value of functions that could fail. Use mysqli::error to get a description of why a MySQLi function/method is failing.

You may be running across a limitation of mysqli and the MySQL driver: the lower level mysql_use_result() or mysql_store_result() must be called on results before they can be used. By default, mysqli_stmt::execute probably calls mysql_use_result, which means the old result must be closed before a new query is run (which is mentioned in the documentation for mysqli::query()). Proper application of mysqli_stmt::store_result may fix the problem.

Note that you shouldn't need to call mysqli::stmt_init(), which is present (as mysqli_stmt_init) to support procedural programming. Instead, you can use mysqli::prepare().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!