これは私のバグであり、PHPのドキュメントやGoogleの検索結果のどこにも見つからないようなので、ここで誰かが助けてくれるかもしれません。mysqli_stmt_bind_resultが値を返さない
私はvarchar(30)
を返すようにデータベースに単純な要求をしようとしています。
コード:あなたが推測できるとおり
$qryID = "select idPhotos from housesphotos where idHouse = ?";
//Prepare the query
$stmt = mysqli_prepare($link, $qryID);
$x = 106;
//Bind the login parameter to the statement
if(mysqli_stmt_bind_param($stmt, "i", $x)){
if(mysqli_stmt_execute($stmt)){
//Bind every column in the select
if(mysqli_stmt_bind_result($stmt, $photoID)){
// $photoID = mysqli_stmt_fetch($stmt);
echo $photoID;
}
}
}
if(empty($photoID)){
printf("EMPTY");
}
出力がEMPTY
ました。私はこのソリューションを使用しようとしました:Strange issue with mysqli_stmt_bind_resultしかし、それは動作しませんでした。
select idPhotos from housesphotos where idHouse = 106
OUTPUT:
591219e92b2fe_591219e92b302
housephotos
がvarchar(30)
フィールドです。私は、それが戻り値を混乱させているフィールド型であるかどうかは分かりません。私はコードで以前に作成した接続であるかどうかもわかりませんが、問題を解決するためにunset($stmt)
などの変数を試しましたが、動作しません。
これはmysqli_stmt_bind_result()
のバグか、新しい人の間違いですか?