本文介紹了MYSQLi bind_result 返回 null的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我試圖在查詢中輸出從數(shù)據(jù)庫中獲取的變量,但沒有返回任何內容.使用 MYSQLi 準備好的語句.
I am trying to output the variables that I get from the database in my query but nothing is being returned. Using MYSQLi prepared statements.
請看下面的代碼:
$stmt = $con->prepare("SELECT first_name, last_name FROM transactions WHERE order_id = ?");
$stmt->bind_param('i', $order_id);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($first_name, $last_name);
$stmt->close();
// Output review live to page
echo $first_name;
我哪里出錯了?
推薦答案
您忘記了獲取結果的行.fetch()
.
You forgot the line to fetch the result. fetch()
.
試試:
$stmt->bind_result($first_name, $last_name);
$stmt->fetch(); // ----- > you forget that line to fetch results.
$stmt->close();
這篇關于MYSQLi bind_result 返回 null的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!