$sql = 'insert into user(account,password,mail,phone,) VALUES ('.$account.','.$password.','.$mail.','.$phone.')';
$query = $this->link->query($sql);往數(shù)據(jù)庫插入數(shù)據(jù)時(shí),VALUES括號內(nèi)要以變量的形式書寫,像上面這種書寫方式正不正確?
5 回答

墨色風(fēng)雨
TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊
$sql = "insert into user(account,password,mail,phone) VALUES ('".$account."','".$password."','".$mail."','".$phone."')";

慕尼黑5688855
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
$sql = "insert into user(account, password, mail, phone) VALUES ('{$account}', '{$password}', '{$mail}', '{$phone}')";
- 雙引號里可以直接寫變量,怕看不清可以加大括號隔離開
- 不知道用的框架還是寫的原生,應(yīng)該有防注入的寫法吧,那個(gè)也挺清楚
- 5 回答
- 0 關(guān)注
- 498 瀏覽
添加回答
舉報(bào)
0/150
提交
取消