$sql = 'insert into user(account,password,mail,phone,) VALUES ('.$account.','.$password.','.$mail.','.$phone.')';
$query = $this->link->query($sql);往数据库插入数据时,VALUES括号内要以变量的形式书写,像上面这种书写方式正不正确?
5 回答
![?](http://img1.sycdn.imooc.com/54585094000184e602200220-100-100.jpg)
墨色风雨
TA贡献1853条经验 获得超6个赞
$sql = "insert into user(account,password,mail,phone) VALUES ('".$account."','".$password."','".$mail."','".$phone."')";
![?](http://img1.sycdn.imooc.com/5333a2320001acdd02000200-100-100.jpg)
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
$sql = "insert into user(account, password, mail, phone) VALUES ('{$account}', '{$password}', '{$mail}', '{$phone}')";
- 双引号里可以直接写变量,怕看不清可以加大括号隔离开
- 不知道用的框架还是写的原生,应该有防注入的写法吧,那个也挺清楚
- 5 回答
- 0 关注
- 450 浏览
添加回答
举报
0/150
提交
取消