Wednesday, October 31, 2018

php - Call to a member function execute() on boolean in




My html :



 


Email :
Message :




My rent.php file :



 require_once 'login.php';

$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) {
die($conn->connect_error);
}
$query = "SET NAMES utf8";
$result = $conn->query($query);
if (!$result) {
die($conn->error);
}


$req = $conn->prepare('INSET INTO renter (email, msg_text) VALUES(?, ?)');
$req->execute(array($_POST['email'], $_POST['msg_text']));

header('Location: menu.php');


My error when I try to submit, is : Fatal error: Call to a member function execute() on boolean in C:...\rent.php on line 18



email, msg_text are in varchar type


Answer




mysqli->prepare can also return FALSE (check http://php.net/manual/en/mysqli.prepare.php) if an error occurred. Your problem is that you have INSET instead of INSERT.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...