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