可能重复:
Best way to stop SQL Injection in PHP
我有一段将代码输入数据库的代码。
代码:
$database->sendUserMessage("You have a new profile comment", "To view your new profile comment, go to your <a href='profile.php?id=$user#comments'>profie</a>.", $user);
INSERT INTO ".TBL_MESSAGES." VALUES (NULL, '$title', '$message', '2', '$user', '0', '0', '0', '0', '0', NULL, NULL, NULL, NULL, now())我遇到的问题是,当试图将HTML传递到查询并执行时,它将不会执行。但是,如果我删除HTML,查询就会正常工作。
有办法绕道吗?
谢谢。
发布于 2011-09-12 09:54:48
你必须逃离你的'
mysql_real_escape_string($html)整个背景:
mysql_query("INSERT INTO ".TBL_MESSAGES." VALUES (NULL, '".mysql_real_escape_string($title)."', '".mysql_real_escape_string($message)."', '2', '$user', '0', '0', '0', '0', '0', NULL, NULL, NULL, NULL, now()");发布于 2011-09-12 10:00:04
你在注入你自己的数据库!您需要用它们的html实体等效替换s。(使用mysql_real_escape_string函数)
https://stackoverflow.com/questions/7386050
复制相似问题