0
我想獲取此行並將其保存到$notescheck
中,但是當我嘗試執行此操作時,$notescheck
爲空,當我要回顯並且沒有錯誤時。使用未準備好的聲明,它工作正常。
準備好的語句獲取行不會返回任何內容
代碼:
if($user_ok == true) {
$sql = "SELECT notescheck FROM users WHERE username=? LIMIT 1";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s",$log_username);
$stmt->execute();
$row = $stmt->fetch();
$notescheck = $row[0];
$stmt->close();
}
對於非事先準備好的聲明它是這樣的:
if($user_ok == true) {
$sql = "SELECT notescheck FROM users WHERE username='$log_username' LIMIT 1";
$query = mysqli_query($conn, $sql);
$row = mysqli_fetch_row($query);
$notescheck = $row[0];
mysqli_close($conn);
}