Correct PHP method to store special chars in MySQL DB

后端 未结 4 1503
刺人心
刺人心 2020-12-20 19:14

Using PHP, what is the best way to store special characters (like the following) in a MSQUL database, to avoid injections.

« \" \' é à ù

Th

4条回答
  •  时光取名叫无心
    2020-12-20 19:55

    Use utf8 encoding to store these values.

    To avoid injections use mysql_real_escape_string() (or prepared statements).

    To protect from XSS use htmlspecialchars.

提交回复
热议问题