I have this MYSQLi query below. The connection to the database is no problem. I tried to use bind_result
too, it could retrieve the data without any problem. However when I use select *
statement, it returned the result only True
or False
. It didn't return any data. Is there anything wrong?
Error: returned from PHP
Fatal error: Call to a member function fetch_array() on boolean in line 20
Code:
$conn = new CDatabase();
$mysqli = $conn->dbConnect();
$sqlstmt = "SELECT * FROM general_staff WHERE generalstaff_userid =? AND generalstaff_password =? LIMIT 1";
if ($mysqli->connect_error) { echo "Connection failure."; }
if($stmt = $mysqli->prepare($sqlstmt)){
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$stmt->store_result();
$stmt_result = $stmt->get_result();
$stmt_rows = $stmt->num_rows();
if ($stmt_rows >0) {
while ($row = $stmt_result->fetch_array()){
echo $row[1];
}
}
?>
By adding this code below to get error code, it returned 1193
if (!$mysqli->query("SET a=1")) {
printf("Errorcode: %d\n", $mysqli->errno);