[英]Empty MySQLi prepared statement results
我只是想選擇數據庫中的特定行,但是由於某種原因,我的結果集一直保持空白。 但是,當我在HeidiSQL中運行查詢時,會得到結果。
我很沮喪 我的代碼沒有發現任何特別錯誤,並且我嘗試回顯$mysqli->error
,但是我沒有任何錯誤。 我還添加了ini_set('display_errors', 'On'); error_reporting(E_ALL);
ini_set('display_errors', 'On'); error_reporting(E_ALL);
我的代碼。
$id =$_GET['sysid'];
$system_info = $mysqli->prepare("SELECT * FROM systems WHERE systems.id = ?");
$system_info->bind_param("i", $id);
$system_info->execute();
$system_info->store_result();
$system_info->bind_result($system_id, $system_name, $system_img);
您需要fetch
結果。
$id = $_GET['sysid'];
$system_info = $mysqli->prepare("SELECT * FROM systems WHERE systems.id = ?");
$system_info->bind_param("i", $id);
$system_info->execute();
$system_info->bind_result($system_id, $system_name, $system_img);
$system_info->fetch();
然后,您可以使用$system_id
, $system_name
和$system_img
。
store_result
將返回一個mysqli_result
對象; 它忽略bind_result
。
$id = $_GET['sysid'];
$system_info = $mysqli->prepare("SELECT * FROM systems WHERE systems.id = ?");
$system_info->bind_param("i", $id);
$system_info->execute();
$result = $system_info->store_result();
list($system_id, $system_name, $system_img) = $result->fetch_array(MYSQLI_NUM);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.