0
我做一個加法論壇{} PHP列計數不在行匹配值計數1
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');
}
的選擇需要從car_name
(ID,姓名)讀取值和car_class
id
但是,當我點擊提交給我 Column count doesn't match value count at row 1
凡與此代碼的問題?
謝謝你從上面解決
編輯 問題。 現在的腳本工作,但不寫入值id_car_name
只寫0
car_class.id_car_name = car_name.id
爲什麼還是這個問題呢?
哦,是謝謝你,現在 工作,但不加'id_car_name'只寫0 'car_class.id_car_name = car_name.id' – Martinovska
當你使用var_dump(intval($ _REQUEST ['id_car_name']))。你得到了什麼 ? – Imanez
什麼要放置以輸入正確的值? – Martinovska