-1
我得到這個錯誤:的MySQL和PHP錯誤十進制值
錯誤:INSERT INTO Ceny
(Umowy_idUmowy
,Cena1
,Cena2
,Cena3
,Cena4
,Cena5
,Cena6
,Cena7
,Cena8
,Cena9
,Cena10
)VALUES( 2,234,90,120,60,15,...,); 你的SQL語法有錯誤;請檢查與您的MySQL服務器版本對應的手冊,以獲得正確的語法爲在'1,',''處使用'1'
Cena1,Cena2等是十進制值。
這是我的代碼:
function add_prices($mysql, $idUmowy, $cena1, $cena2, $cena3, $cena4, $cena5, $cena6, $cena7, $cena8, $cena9, $cena10)
{
$query = "INSERT INTO `Ceny` (`Umowy_idUmowy`, `Cena1`, `Cena2`, `Cena3`, `Cena4`, `Cena5`, `Cena6`, `Cena7`, `Cena8`, `Cena9`, `Cena10`) VALUES ($idUmowy, $cena1, $cena2, $cena3, $cena4, $cena5, $cena6, $cena7, $cena8, $cena9, $cena10);";
if ($mysql->query($query) === TRUE)
{
return;
}
else
{
echo 'Error: ' . $query . '<br>' . $mysql->error;
return;
}
}
請你們HELP :-)
模式結構:MySql Workbench
架構代碼:
CREATE TABLE IF NOT EXISTS `klusek73_umowy`.`Ceny` (
`idCeny` INT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
`Umowy_idUmowy` INT UNSIGNED ZEROFILL NOT NULL,
`Cena1` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena2` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena3` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena4` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena5` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena6` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena7` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena8` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena9` DECIMAL(7,2) UNSIGNED NOT NULL,
`Cena10` DECIMAL(7,2) UNSIGNED NOT NULL,
PRIMARY KEY (`idCeny`, `Umowy_idUmowy`),
UNIQUE INDEX `idCeny_UNIQUE` (`idCeny` ASC),
INDEX `fk_Ceny_Umowy1_idx` (`Umowy_idUmowy` ASC),
UNIQUE INDEX `Umowy_idUmowy_UNIQUE` (`Umowy_idUmowy` ASC),
CONSTRAINT `fk_Ceny_Umowy1`
FOREIGN KEY (`Umowy_idUmowy`)
REFERENCES `klusek73_umowy`.`Umowy` (`idUmowy`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
看起來像$ cena7,$ cena8,$ cena9,$ cena10是空的...... – Dekel
'60,15,,,,,);'不明顯? –
是的,我希望它保持這樣。可能嗎? – phpWarrior