Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想问你,mysql_real_escape_string()如果数据是使用函数在我的 JS 文件中编码的,是否有必要对我在 PHP ajax 文件中发送到我的数据库的数据使用 PHPencodeURIComponent()函数?谢谢
mysql_real_escape_string()
encodeURIComponent()
是的。encodeURIComponent对字符进行编码,这样它们就不会在 URL 中被误解(通过 HTTP 传输);mysql_real_escape_string转义字符串,以便它不会在 MySQL 查询(数据库内部)中被误解。
encodeURIComponent
mysql_real_escape_string
换句话说,每个都有完全不同的功能;更不用说您零保证您的 PHP 文件中的请求实际上来自您的 AJAX 调用。