gpt4 book ai didi

php - MySQL 错误 - “You have an error in your SQL syntax"

转载 作者:行者123 更新时间:2023-12-01 00:03:43 24 4
gpt4 key购买 nike

<分区>

我的代码是:

if (isset($_POST['add'])) {
$query = "INSERT INTO ".$dbPrefix."posts (`id`, `user`, `name`, `link`, `content`, `date`, `private`, `password`) VALUES (NULL, '$user', '$name', '$link', '$content', '$date', '$private', '$pass');";
$mysqli->query($query) OR $status = 'Oprostite, pri dodajanju je prišlo do težave.';
$id=$mysqli->insert_id;
foreach ($_POST['categories'] as $category) {
$categoryQuery.="INSERT INTO ".$dbPrefix."category_posts (`categoryID`, `postID`) VALUES ('".$category."','".$id."');";
}
$mysqli->query($categoryQuery) OR $status = $mysqli->error;
}
echo $status;

我的变量 $_POST 是:

Array(    [name] => ((((((((((    [description] => ))))))    [keywords] =>     [categories] => Array        (            [0] => 1            [1] => 2            [2] => 3        )    [private] => 0    [password] =>     [date] => 0    [datetime] =>     [add] => Dodaj)

If I print the query and run it in phpMyAdmin there is no problem, otherwise it will display an error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO fc_category_posts (`categoryID`, `postID`) VALUES ('2','116');INSERT' at line 1

Query is:

INSERT INTO fc_category_posts (`categoryID`, `postID`) VALUES ('1','116');
INSERT INTO fc_category_posts (`categoryID`, `postID`) VALUES ('2','116');
INSERT INTO fc_category_posts (`categoryID`, `postID`) VALUES ('3','116');

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