将文件上传到cPanel时出现“Mysqli_stmt :: get_result()”错误。
所以我决定通过实现get_result()的新函数来改变代码。
当我实现该代码时,我不断收到错误,如下图所示。
我的代码如下,我评论了具体的行号
<?php
function get_result( $Statement) {
$RESULT = array();
$Statement->store_result(); *Line 5* <--
for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
$Metadata = $Statement->result_metadata();
$PARAMS = array();
while ( $Field = $Metadata->fetch_field() ) {
$PARAMS[] = &$RESULT[ $i ][ $Field->name ];
}
call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
$Statement->fetch();
}
return $RESULT;
}
$link = new mysqli("localhost","user","123","database");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT * FROM job_book";
$query = $link->prepare($sql);
$query->execute();
$RESULT = get_result( $Statement); *Line 30* <--
if($RESULT = $query->get_result())
{
if($RESULT->num_rows > 0)
{
echo "<table><thead>";
.
.
.
cont'd...
如果有人能够追踪问题所在,我会非常高兴。谢谢!
答案 0 :(得分:0)
您需要更改第30行:
if ($result = $query->get_result()) {
if ($result->num_rows > 0) {
echo "<table><thead>";
while ($row = $result->fetch_assoc()) {
...
}
}
}