gpt4 book ai didi

php - INSERT INTO 数据库不起作用

转载 作者:行者123 更新时间:2023-11-29 21:14:32 24 4
gpt4 key购买 nike

我正在尝试将数据输入数据库(这是一个 react 脚本),但我总是收到错误,这让我发疯。

这是我正在使用的代码:

    if (mysql_query("INSERT INTO gastenboek (naam, bericht, datum, ip, plantid) VALUES ('".trim(mysql_real_escape_string($_POST['naam']))."', '".trim(mysql_real_escape_string($_POST['bericht']))."', $datum_reactie, '".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."', $id)")) {
echo '<span style="color:green; font-weight: bold"Je reactie is succesvol toegevoegd!</span>';
} else {
echo '<span style="color:green; font-weight: bold">Er is iets fout gegaan en je reactie is niet toegevoegd. Probeer het later opnieuw.</span>';
}

这似乎不起作用。但是当我使用以下代码显示数据时:

    if (mysql_query("INSERT INTO gastenboek (naam, bericht, datum, ip, plantid) VALUES ('".trim(mysql_real_escape_string($_POST['naam']))."', '".trim(mysql_real_escape_string($_POST['bericht']))."', $datum_reactie, '".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."', $id)")) {
echo '<span style="color:green; font-weight: bold"Je reactie is succesvol toegevoegd!</span>';
} else {
echo '<span style="color:green; font-weight: bold">Er is iets fout gegaan en je reactie is niet toegevoegd. Probeer het later opnieuw.</span>';
$qry = "INSERT INTO gastenboek (naam, bericht, datum, ip, plantid) VALUES ('".trim(mysql_real_escape_string($_POST['naam']))."', '".trim(mysql_real_escape_string($_POST['bericht']))."', $datum_reactie, '".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."', $id)"; echo $qry;
}

这就是我得到的: enter image description here

所以一切似乎都正确?

这就是我的数据库的样子: enter image description here

最佳答案

尝试引用您的“日期”字段。这可能会为您解决问题。

关于php - INSERT INTO 数据库不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36071540/

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