mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in บรรทัดที่ 23 ครับเอามาจำลองฝนเครื่อง
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include('includes/connection.php');
if(empty($_POST['username']) || empty($_POST['password'])){
//include('msg_login_chk.php');
header('Refresh:0; url=index.php');
//echo "1";
exit();
}
$username = mysqli_real_escape_string($connect,$_POST['username']);
$password = mysqli_real_escape_string($connect,$_POST['password']);
$sql = "select * from member where username='$username' and pass='$password' and status='Y'";
$result = mysqli_query($connect,$sql);
$row = mysqli_fetch_array($result);
if($row!=0)
{session_start();
$_SESSION['sess_userid']=session_id();
$_SESSION['sess_member_id']=$row['member_id'];
$log_date=date('Y-m-d ');
$log_time=date("H:m:s");
mysqli_query($connect,"insert into member_log values ('','$log_date','$log_time','".$_SERVER["REMOTE_ADDR"]."','".$_SESSION['sess_member_id']."')");
header('location:index.php');
//echo $_SESSION['sess_userid'];
exit();
}else{
//require('msg_login_chk.php');
//header('Refresh:1; url=index.php');
echo $sql;
exit();
}
mysqli_close($connect);
session_write_close();
?>Tag : PHP
Date :
2022-09-08 11:08:21
By :
koncept
View :
442
Reply :
1
ลองเปลี่ยน query เป็น prepare statement
ตัวอย่าง
$sql = "SELECT * FROM users WHERE id=?"; // SQL with parameters
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result(); // get the mysqli result
$user = $result->fetch_assoc(); // fetch data
Date :
2022-09-08 15:00:55
By :
009
Load balance : Server 02