由于我在这里看到如此多的低质量评论,这是一个粗略的未经测试的答案.
$query = "INSERT INTO table (Column) VALUES (?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s", $val1);
$val1 = "thats'one";
$stmt->execute();
Run Code Online (Sandbox Code Playgroud)
这假设$mysqli是你的连接对象.
关于该主题的其他链接:
http://php.net/manual/en/mysqli-stmt.execute.php
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
https://www.owasp.org/ index.php/SQL_Injection_Prevention_Cheat_Sheet #Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29
http://php.net/manual/en/security.database.sql-injection.php
如何在PHP中阻止SQL注入?
| 归档时间: |
|
| 查看次数: |
568 次 |
| 最近记录: |