本文介紹了MYSQLi bind_result 返回 null的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我試圖在查詢中輸出從數(shù)據(jù)庫中獲取的變量,但沒有返回任何內(nèi)容.使用 MYSQLi 準(zhǔn)備好的語句.
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.
請(qǐng)看下面的代碼:
$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;
我哪里出錯(cuò)了?
推薦答案
您忘記了獲取結(jié)果的行.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();
這篇關(guān)于MYSQLi bind_result 返回 null的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!