我想製作一個表格,將數據插入到表中,但它不會正常工作;每次它都會回顯:「列計數與第1行的值計數不匹配」。希望這裏有人能說出我做錯了什麼。如何正確地將這些數據插入MySql表中?
我的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>';
?>
編輯:好吧,真的沒有想到過的第一篇文章,但現在我改變了一切它仍然不會工作..
定義「但它不會正常工作」... – GDP
你能解釋它是如何不工作? – DrinkJavaCodeJava