[英]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. 美好的一天,我对PHP不太熟悉,尝试执行查询时遇到此错误。
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
致命错误:未捕获错误:在C:\\ xampp \\ htdocs \\ LoginWithMySQLi \\ changenameaction.php:12中的布尔值上调用成员函数bind_param():12堆栈跟踪:#0 {main}抛出在C:\\ xampp \\ htdocs \\ LoginWithMySQLi \\第12行的changenameaction.php
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 sql语句未能通过准备阶段,因此您应在继续其他方法之前测试该语句是否正常-原因是
WHERE
子句之前的逗号
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 = ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.