gpt4 book ai didi

php - 无法插入指向数据库的链接

转载 作者:行者123 更新时间:2023-12-01 00:46:22 25 4
gpt4 key购买 nike

我有这个代码:

    if (!empty($_POST['w1']) && !empty($_POST['l1']))   {
$str = "<a href='".$_POST['l1']."'>".$_POST['w1']."</a>";
$content = str_replace($_POST['w1'],$str, $content);
}
$content = nl2br($content);
echo "נוסף";
echo $content;
mysql_query("INSERT INTO `posts` VALUES ('','".$_POST['subject']."','$content','0')");

php 页面没有返回任何错误。但是数据没有插入到数据库中。任何人都知道这是什么问题?

最佳答案

如果抛出任何 mysql 错误,则不会显示给您。执行以下操作以查看错误:

mysql_query("INSERT INTO `posts` VALUES ('','". mysql_real_escape_string($_POST['subject']) . "','" . mysql_real_escape_string($content) . "','0')") or die mysql_error();

注意 SQL 注入(inject)!

关于php - 无法插入指向数据库的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21598490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com