在我的本地/开发环境中,MySQLi查询执行正常.但是,当我在我的Web主机环境中上传它时,我收到此错误:
致命错误:在...中的非对象上调用成员函数bind_param()
这是代码:
global $mysqli;
$stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?");
$stmt->bind_param('i', $cur_id);
$stmt->execute();
$stmt->bind_result($uid, $desc);
Run Code Online (Sandbox Code Playgroud)
为了检查我的查询,我试图通过控制面板phpMyAdmin执行查询,结果是OK.
如果我使用这样的代码:
$update_result = mysqli_query( $link , $sql_update_login ) or die ('Unable to execute query. '. mysqli_error($link));
Run Code Online (Sandbox Code Playgroud)
它是否必须死亡或者您之后可以提出不同的查询?就像将错误日志写入另一个表的预定函数一样?如:
$update_result = mysqli_query( $link , $sql_update_login ) or function('$query, $error);
Run Code Online (Sandbox Code Playgroud)
'或'之后的其他选项有哪些?我没有在文档中找到它,任何线索都表示赞赏.
如果第一个语句失败,则返回FALSE.要从其他语句中检索后续错误,您必须先调用mysqli_next_result().
成功时返回TRUE,失败时返回FALSE.
最后,在文档中发布的示例multi_query使用返回值next_result来确定何时不再有查询; 例如,停止循环:
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* execute multi query */
if ($mysqli->multi_query($query)) {
do {
/* store first result set */
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
printf("%s\n", …Run Code Online (Sandbox Code Playgroud) 在我的代码中,我执行了几个有效的 SQL 语句。但是其中一条语句无效($mysqli->prepare 返回false),但没有返回错误代码($mysqli->error 返回false)。
这是代码的示例:
$mysqli = new mysqli('host', 'user', 'password', 'database');
// First query (valid)
if(($oStatement = $mysqli->prepare('SELECT column FROM table;')) === false)
throw new Exception('Error in statement: ' . $mysqli->error);
// ...
// Second query (invalid)
if(($oStatement = $mysqli->prepare('SELECT column_which_doesnt_exist FROM table;')) === false)
throw new Exception('Error in statement: ' . $mysqli->error);
Run Code Online (Sandbox Code Playgroud)
为什么不返回错误信息?