我正在尝试制作一个将数据插入表格的表格,但它无法正常工作;每次它都会回显:“列数与第 1 行的值计数不匹配”。希望这里有人能告诉我我做错了什么。
我的 SQL 表:
CREATE TABLE IF NOT EXISTS `products` (
`serial` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) COLLATE latin1_general_ci NOT NULL,
`description` varchar(255) COLLATE latin1_general_ci NOT NULL,
`price` float NOT NULL,
`picture` varchar(80) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`serial`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=7 ;
我的表格:
<?php
include('config.php');
echo '<h1 style="font-size:20px;">Sieraad toevoegen</h1>';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['naam']) || empty($_POST['prijs'])) {
echo '<span style="color:red"><b>Niet alle velden zijn ingevuld!</b></span>';
} else {
mysql_query("INSERT INTO products (name, description, picture, price) VALUES ('$_POST[naam]','$_POST[beschrijving]','$_POST[foto]', '$_POST[prijs]', NOW())") or die (mysql_error());
echo '<span style="color:green"><b>Het sieraad is succesvol toegevoegd!</b></span>';
}
}
echo '<form method="post" target="_self">';
echo '<input type="hidden" name="serial">';
echo 'Naam van sieraad:<br><input type="text" name="naam"><br>';
echo 'Beschrijving:<br><textarea type="text" maxlength="250" name="beschrijving" rows="6" cols="37"></textarea><br>';
/**echo '<input name="MAX_FILE_SIZE" value="102400" type="hidden">';**/
echo 'Foto:<br><input type="text" name="foto"><br>';
echo 'Prijs:<br><input type="text" name="prijs" maxlength:"7"><br>';
echo '<input type="submit" value="Toevoegen" onclick="this.value=\'Sieraad wordt verwerkt...\';"> <input type="reset" value="Wis velden">';
echo '</form>';
?>
编辑:好的,并没有真正考虑过第一篇文章,但现在我改变了一切,它仍然无法工作..