Hello. I am having an error and it says:
Fatal error : Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\Practice\exam.php:727 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Practice\exam.php on line 727 can anyone help me? I am beginner in PHP. Thank you.
if (!empty($FirstName) || !empty($MiddleName) || !empty($LastName) || !empty($Age) || !empty($HomeAddress) || !empty($ContactNumber) || !empty($LastSchoolAttended))
{
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "studentsinformation";
}
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error())
{
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
}
else
{
$SELECT = "SELECT FirstName, MiddleName, LastName, LastSchoolAttended From information Where FirstName = ? And MiddleName = ? And LastName = ? And LastSchoolAttended = ? Limit 1";
$INSERT = "INSERT Into information (FirstName, MiddleName, LastName, Age, HomeAddress, ContactNumber, LastSchoolAttended) values (?,?,?,?,?,?,?)";
$stmt = $conn->prepare($SELECT);
$stmt -> bind_param("ssss", $FirstName,$MiddleName,$LastName,$LastSchoolAttended); **this is where I got an error. LINE 727**
$stmt -> execute();
$stmt -> bind_result($FirstName,$MiddleName,$LastName,$LastSchoolAttended);
$stmt -> store_result();
$rnum = $stmt -> num_rows;
if ($rnum == 0 ) {
$stmt->close();
$stmt = $conn -> prepare($INSERT);
$stmt -> bind_param("sssisis", $FirstName,$MiddleName,$LastName,$Age,$HomeAddress,$ContactNumber,$LastSchoolAttended);
$stmt -> execute();
}
}
?>