警告:mysqli_stmt :: close()[mysqli-stmt.close]:无效的对象或资源mysqli_stmt ...为什么?

时间:2011-09-04 05:49:20

标签: php prepared-statement

出于学习目的,为什么php会对以下代码发出呐喊并发出以下警告:

Warning: mysqli_stmt::close() [mysqli-stmt.close]: invalid object or resource mysqli_stmt in C:\public_html\admin\disctrack.php on line 14


12    $conn = connect('w'); // connect to a database in write mode
13    $stmt = $conn->stmt_init(); // initialize a prepared statement
14    $stmt->close(); // close statement

1 个答案:

答案 0 :(得分:2)

来自mysqli::stmt_init documentation

  

在调用mysqli_stmt_prepare()之前,对任何mysqli_stmt函数的任何后续调用都将失败。