Good day, I'm not really familiar with PHP and i get this error when i try to execute my query.
Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:\\xampp\\htdocs\\LoginWithMySQLi\\changenameaction.php:12 Stack trace: #0 {main} thrown in C:\\xampp\\htdocs\\LoginWithMySQLi\\changenameaction.php on line 12
here's my code:
session_start();
require_once 'dbconnect.php';
$stmt = $DBcon->prepare("UPDATE tbl_users SET fname = ?, lname = ?, WHERE user_id = ?");
$stmt->bind_param('sss', $_POST['fname'], $_POST['lname'], $_SESSION['userSession']);
$stmt->execute();
$stmt->close();
$DBcon->close();
Do you know what i do wrong?
Thanks in Advance
The sql statement was failing the preparation stage so you should test that the statement is ok before proceeding with the other methods - the reason it failed was the extra comma before the WHERE
clause
session_start();
require_once 'dbconnect.php';
$stmt = $DBcon->prepare("UPDATE tbl_users SET fname = ?, lname = ? WHERE user_id = ?");
if( $stmt && isset($_POST['fname'], $_POST['lname'], $_SESSION['userSession']) ){
$stmt->bind_param('sss', $_POST['fname'], $_POST['lname'], $_SESSION['userSession'] );
$stmt->execute();
$stmt->close();
}
$DBcon->close();
你有一个逗号结尾,你的sql应该像这样
UPDATE tbl_users SET fname = ?, lname = ? WHERE user_id = ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.