Ant*_*cia 6 php mysql sql-injection html-encode html-entities
使用PHP,在MSQUL数据库中存储特殊字符(如下所示)的最佳方法是什么,以避免注入.
« " ' é à ù
Run Code Online (Sandbox Code Playgroud)
这是我现在这样做的方式:
$book_text=$_POST['book_text'];
$book_text=htmlentities($book_text, "ENT_QUOTES");
$query=//DB query to insert the text
Run Code Online (Sandbox Code Playgroud)
然后:
$query=//DB query to select the text
$fetch=//The fetch of $book_text
$book_text=html_entity_decode($book_text);
Run Code Online (Sandbox Code Playgroud)
这样,我的所有文本都以HTML实体格式化.但我认为这占用了大量的数据库空间.那么,有更好的方法吗?
| 归档时间: |
|
| 查看次数: |
11957 次 |
| 最近记录: |