為什麼我在rent.php 中收到「呼叫布林值上的成員函數execute()」?

Susan Sarandon
發布: 2024-11-14 21:00:03
原創
952 人瀏覽過

Why Am I Getting

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 中收到「呼叫布林值上的成員函數execute()」?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板