msqli_* prevent SQL injection

To avoid your code be vulnerable, especially for preventing SQL injection. You may need the mysqli_* function and prepare statement of it to make it.

I will make some examples, such like this:

  • The SELECT sentence like this:
$stmt = $conn->prepare('SELECT column_name FROM table_name WHERE column_name = ?');
$stmt->bind_param('s', $varname);
$stmt->execute();
$result = $stmt->get_result();
  • The INSERT sentence like this:
$stmt = $conn->prepare('INSERT INTO table_name(column_name_f, column_name_s) VALUES(?,?)');
$stmt->bind_param('ss', $var_name_f, $var_name_s);
$stmt->execute();
$stmt->close();

So the only question you guys want to know is that mysterious ‘s’.
Not other mean, just String.

And other’s just as the word the said.
- bind_param which bind param like $var_name_f with the first question mark in this string(’s’) format.
- execute means that the statement will execute the sql sentence.
- close, just close connection;

上一篇: kali install pip3
下一篇: CSS Layout
ReZerou
博客等级 码龄10年 19粉丝 119原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值