gpt4 book ai didi

php - {php} 列计数与第 1 行的值计数不匹配

转载 作者:行者123 更新时间:2023-11-29 07:12:57 25 4
gpt4 key购买 nike

我创建了一个添加论坛

if ($_SERVER['REQUEST_METHOD'] == "POST" AND isset ($_REQUEST['addfinal'])) {

$name_1 = clear_form_text ($_REQUEST['name_1']);
$name_2 = clear_form_text ($_REQUEST['name_2']);
$car_name = intval ($_REQUEST['id_car_name']);


if (empty ($name_1)) $stop .= "Error text!<br>";
if (empty ($name_2)) $stop .= "Error text!<br>";

if ($stop == false) {

$db->query ("INSERT INTO car_class (name_1, name_2, id_car_name) VALUES ('$name_1', '$name_2' '$car_name')") or die ($db->error);
$infomessage = "<div class=\"attention-box attention-success\"><p class=\"text-muted\">Add success. <a href=\"index.php?module=school_class\">Back</a></p></div>";

} else {

$infomessage = "<div class=\"attention-box attention-danger\"><p class=\"text-muted\">" . $stop . " <a href=\"javascript:history.back();\">Врати се назад</a></p></div>";

}

} else {

$result = $db->query("SELECT id, name FROM car_name");
while ($row = $result ->fetch_array())
$arrayrow[] = $row;

foreach ($arrayrow as $row) {
$select .= "<option value='".$row['id']."'>".$row['name']."</option>";

}

$template->set_block ('car_class-add', '', 'car_class');
$template->set ('car_name', $select, 'car_class');

}

Select 需要从 car_name 中读取值(id, name)并将其写入 idcar_class

但是当我点击提交时给我列计数与第 1 行的值计数不匹配

这段代码的问题出在哪里?

谢谢

编辑上面的问题就解决了。现在脚本可以工作,但不在 id_car_name 中写入值,仅写入 0car_class.id_car_na‌​me = car_name.id 为什么还是这个问题?

最佳答案

您必须在“$name_2”后添加逗号:

 $db->query ("INSERT INTO car_class 
(name_1, name_2, id_car_name)
VALUES ('$name_1', '$name_2', '$car_name')")
or die ($db->error);

关于php - {php} 列计数与第 1 行的值计数不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38991129/

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