Php SQL注入和转义特殊字符
我接受TinyMCE的数据。当我从这样的站点复制和粘贴时,我会遇到困难:Php SQL注入和转义特殊字符,php,mysql,tinymce,Php,Mysql,Tinymce,我接受TinyMCE的数据。当我从这样的站点复制和粘贴时,我会遇到困难: http://www.rlslog.net/category/games/pc/ 我使用以下函数来防止SQL注入和转义特殊字符,一旦我输出插入的文本,这些字符就会破坏我的整个页面 $title = mysql_real_escape_string($title); $data = mysql_real_escape_string($data); $author= mysql_real_escape_string($aut
http://www.rlslog.net/category/games/pc/
我使用以下函数来防止SQL注入和转义特殊字符,一旦我输出插入的文本,这些字符就会破坏我的整个页面
$title = mysql_real_escape_string($title);
$data = mysql_real_escape_string($data);
$author= mysql_real_escape_string($author);
$data =htmlentities($data);
$title =htmlentities($title);
$author =htmlentities($author);
mysql_query("SET NAMES 'utf8'");
mysql_query("INSERT INTO `easy_db`.`article` (`Title`, `Article`, `Topics`, `author`, `page`, tpage ) VALUES('$title', '$data', '$topic', '$author', '$page','$tpage')") or die(mysql_error());
mysql_close();
当我输出数据时得到的是html文本(它不是数据库的输出),如下所示:
כותרת היו×
我在php.ini中关闭了magic_quotes_gpc
magic_quotes_gpc
Default Value: Off
Development Value: Off
Production Value: Off
以下是我在phpmyadmin中引用的文本的外观:
skidrow%2F&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35\" frameborder=\"0\" scrolling=\"no\"></iframe></p>\r\n<p class=\"comments_link\" style=\"padding-top: 20px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; line-height: 19px; margin: 0px;\"><a style=\"color:
c02e13; text-decoration: none; padding: 0px; margin: 0px;\" title=\"Comment on Orcs Must Die Fix-SKIDROW\"
href=\"http://www.rlslog.net/orcs-must-die-fix-skidrow/#respond\">Comments(0)</a></p>\r\n</div>\r\n</div>\r\n<div style=\"padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 40px; margin: 0px;\"><iframe style=\"padding: 0px; margin: 0px;\" src=\"http://www.roadcomponentsdb.com/300.htm\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"NO\" width=\"300\" height=\"250\"></iframe></div>\r\n<p id=\"nextlinks\" style=\"padding-top: 20px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; margin: 0px;\"><strong style=\"padding: 0px; margin: 0px;\">Previous post:</strong> <a style=\"color: #c02e13; text-decoration: none; padding: 0px; margin: 0px;\" href=\"http://www.rlslog.net/musclemag-international-%e2%80%93-december-2011-p2p/\">MuscleMag International – December 2011-P2P</a></p>
skidrow%2F&;布局=标准&;显示面=假&;宽度=450&;行动=喜欢&;配色方案=灯光和;高度=35 \“框架边框=\“0\”滚动=\“否”>\r\n\r\n\r\n\r\n\r\n以前的帖子:
问题是为什么会发生这种情况?我如何防止它?我是否做了足够的工作来防止sql注入?
设置名称“utf8”
正在更改您的数据
看一看。他对正在发生的事情给出了相当好的描述。简短描述:转换过程对于应该将字符读取为什么感到困惑。如果你看我的代码,我已经设置了它。有没有其他方法对该字符串进行编码..有没有php或mysql函数可以消除这种影响happening@DmitryMakovetskiyd你必须删除那句话。它似乎没有任何改善,我仍然得到….כו×ת×תדה™×•×在除了文本之外的所有文本元素中,我输出了不,对不起,它已经改善了情况。现在它停止这样做了。你能告诉我sql注入位的情况吗?我可以安全地避免错误吗injection@DmitryMakovetskiyd是的,你应该这样做。转义字符串和删除HTML几乎涵盖了所有注入尝试。