调用成员函数bind_result

时间:2018-07-26 06:00:37

标签: php mysqli

我输入错误

  

未捕获的错误:在布尔值上调用成员函数execute()

然后如果我删除了$stmt->execute();其他错误

  

未捕获的错误:在布尔值上调用成员函数bind_result()

:(

$conn = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);

if(mysqli_connect_errno()){
    echo "Failed to Connect" .mysqli_connect_errno();
    die();
    }
$stmt = $conn->prepare("SELECT id, customer_id, first_name, last_name, middle_name, path_to_photo_thumbnail FROM customers;");
$stmt->execute();

$stmt->bind_result($id, $customer_id, $first_name, $last_name, $middle_name, $path_to_photo_thumbnail);

$cutomer = array();

while($stmt->fetch()){
    $temp = array();
    $temp['id'] = $id;
    $temp['customer_id'] = $customer_id;
    $temp['first_name'] = $first_name;
    $temp['last_name'] = $last_name;
    $temp['middle_name'] = $middle_name;
    $temp['path_to_photo_thumbnail'] = $path_to_photo_thumbnail;
    array_push($cutomer, $temp);
}
echo json_encode($cutomer)

1 个答案:

答案 0 :(得分:0)

在您的sql语句中将customers;替换为customers