mysql - SQL prepared statements
问题描述
I am getting this error continuously:
Call to a member function bind_param() on boolean*
It generally appears when we try operation on a table that does not exist and prepare statement returns false, but I have a structured table. My prepared statements are:
$query = "INSERT INTO `profiles`(name,email,handle,DOB,profilePic,gender,r_lat,r_lon,c_lat,"
. "c_lon,connections,recentActivities,savedItems,achievements,school,"
. "interestsB,interestsI,interestsE,work,coverPic,bio,fb_url,insta_url,link_url,wordpress_url,"
. "other_url,address,range,phone)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PS: I am open to all suggestions.
$stmt=$mysqli->prepare($query);
$stmt->bind_param("ssssssddddsssssssssssssssssii",$name,$email,$handle,$DOB,$profilePic,$gender,$r_lat,$r_lon,$c_lat,$c_lon,
$connections,$recentActivities,$savedItems,$achievements,$school,$interestsB,
$interestsI,$interestsE,$work,$coverPic,$bio,$fb_url,$insta_url,$link_url,$wordpress_url,
$other_url,$address,$range,$phone);
$res = $stmt->execute();
return $res;
I am posting screenshots:
printing the error returns:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'range,phone)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)' at line 1
解决方案
range
is a reserved word in MySQL. You could escape it by surrounding it with forward quotes:
`range`
推荐阅读
- vba - 未找到名称参数
- c# - 如果日期字段不为空,则将日期字段与今天的日期进行比较
- asp.net-web-api - 如何在 ASP.NET Web 应用程序中实现分散-聚集模式?
- python - 保存 Django 表单数据
- node.js - 如何将一个数据库模型与多个服务器一起使用?
- firebase - 如何从 firestore 查询快照中获取特定的文档数据?
- haskell - [(e) | 是什么意思?e <- list, x /= e] in haskell
- python - 根据 PySpark 中的另一列填充不同的列
- javascript - 为什么 parseInt() 不起作用?
- unity3d - 当角色在跳跃过程中接触墙壁时,重力不起作用