Call to a Member Function execute() on Boolean in rent.php
In PHP programming, you may encounter the error "Call to a member function execute() on boolean" when working with MySQL databases and executing prepared statements using mysqli_prepare and mysqli_execute. This error typically indicates a problem with the SQL statement or the type of data being passed to the execute() function.
In your case, you mentioned that you received this error when executing the following line in your rent.php script:
$req->execute(array($_POST['email'], $_POST['msg_text']));
mysqli_prepare() returns a boolean value (TRUE/FALSE) to indicate whether the SQL statement was prepared successfully. If the statement is not prepared successfully, you should check for errors using mysqli_error() to get more information.
In your case, the error occurred because there is a typo in the SQL statement. You have "INSET" instead of "INSERT" in the SQL statement:
$req = $conn->prepare('INSET INTO renter (email, msg_text) VALUES(?, ?)');
Once you correct the typo to "INSERT", your code should execute as intended and insert the data into the renter table in your database. Remember to always check for errors using mysqli_error() after executing mysqli_prepare() to ensure the statement was prepared successfully.
以上がrent.php で「ブール値でのメンバー関数の実行() の呼び出し」が発生するのはなぜですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。