cpp*_*pit 0 php mysql html-sanitizing input-sanitization
我有一个像这样的mysql语句:
mysql_query("INSERT INTO movies (comments, description, synopsis)
VALUES ('$_POST["comments"]', '$_POST["desc"]',$_POST["synopsis"])");
Run Code Online (Sandbox Code Playgroud)
你可以看到非常简单明了.问题是当我在表单中输入特殊字符时,它不会将数据插入到我的表中(使用phpmyadmin直接检查它是否已插入).例如,如果我在评论textarea这个值:"这是一个评论",如果我改为:"你的名字是什么?:John doe是我的名字"它会中断它.我知道它因为mysql使用了字符......我应该怎么做的任何建议?
mysql_query("INSERT INTO movies (comments, description, synopsis)
VALUES ('".mysql_real_escape_string($_POST["comments"])."', '".mysql_real_escape_string($_POST["desc"])."','".mysql_real_escape_string($_POST["synopsis"])."'");
Run Code Online (Sandbox Code Playgroud)