A. Mousavi A. Mousavi - 14 days ago 4x
MySQL Question

PHP UPDATE with bind_param() won't work

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:


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']);


Do you know what i do wrong?

Thanks in Advance


You hava a trailing comma your sql should be like this

UPDATE tbl_users SET fname = ?, lname = ? WHERE user_id = ?