在我的dbsql文件中,我有两个CREATE TABLES,第一个工作,与插入值相关的php也可以。
无论如何,第二个表不起作用,非常感谢任何帮助,我会把CREAT表语句,然后PHP关联..
CREATE TABLE `Cars` (
`CarId` bigint(20) NOT NULL auto_increment,
`date` date NOT NULL default '0000-00-00',
`uploader` varchar(200) collate latin1_general_ci NOT NULL REFERENCES users(user_name),
`DVLAMake` varchar(200) collate latin1_general_ci NOT NULL default '',
`DVLAModel` varchar(200) collate latin1_general_ci NOT NULL default '',
`BodyStyle` varchar(200) collate latin1_general_ci NOT NULL default '',
`EngineSize` varchar(100) collate latin1_general_ci NOT NULL default '',
`Year` varchar(200) collate latin1_general_ci NOT NULL default '',
`Transmission` varchar(10) collate latin1_general_ci NOT NULL default '',
`FuelType` varchar(10) collate latin1_general_ci NOT NULL default '',
`CurrColour` varchar(50) collate latin1_general_ci NOT NULL default '',
`NoOfDoors` varchar(10) collate latin1_general_ci NOT NULL default '',
`SeatingCap` varchar(10) collate latin1_general_ci NOT NULL default '',
`Length` varchar(10) collate latin1_general_ci NOT NULL default '',
`Width` varchar(10) collate latin1_general_ci NOT NULL default '',
`Height` varchar(10) collate latin1_general_ci NOT NULL default '',
`CombEngCap` varchar(10) collate latin1_general_ci NOT NULL default '',
`DriveType` varchar(10) collate latin1_general_ci NOT NULL default '',
`MaxTorque` varchar(10) collate latin1_general_ci default '',
`MaxPower` varchar(10) collate latin1_general_ci default '',
`FuelConsumpURB` varchar(10) collate latin1_general_ci default '',
`FuelConsumpCOMB` varchar(10) collate latin1_general_ci default '',
`MaxSpeed` varchar(10) collate latin1_general_ci default '',
`Acceleration` varchar(10) collate latin1_general_ci default '',
`WeightKG` varchar(10) collate latin1_general_ci default '',
`NCAPRating` varchar(10) collate latin1_general_ci default '',
`SecRemCentLock` ENUM('T','F') NOT NULL default 'F',
`SecCentLock` ENUM('T','F') NOT NULL default 'F',
`SecAlarm` ENUM('T','F') NOT NULL default 'F',
`SecImmob` ENUM('T','F') NOT NULL default 'F',
`AudioEquip` ENUM('T','F') NOT NULL default 'F',
`ExtPowerAssSteer` ENUM('T','F') NOT NULL default 'F',
`ExtAssBreak` ENUM('T','F') NOT NULL default 'F',
`ExtElecWindows` ENUM('T','F') NOT NULL default 'F',
`ExtAirbags` ENUM('T','F') NOT NULL default 'F',
`ElecMirrors` ENUM('T','F') NOT NULL default 'F',
`ElecHeatedMir` ENUM('T','F') NOT NULL default 'F',
`IncWarranty` ENUM('T','F') NOT NULL default 'F',
`IncSerBook` ENUM('T','F') NOT NULL default 'F',
`IncMOT` ENUM('T','F') NOT NULL default 'F',
`IncPXConsid` ENUM('T','F') NOT NULL default 'F',
`CurrColour` varchar(50) collate latin1_general_ci NOT NULL default '',
`CarImage` varchar(50) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`CarId`),
FULLTEXT KEY `Car_search` (`DVLAMake`,`DVLAModel`,`BodyStyle`,`CurrColour`)
这是php:我没有插入其余部分,因为它在最后一行死了......
<?php
include 'dbc.php';
$path = "uploads/";
$path = $path . basename( $_FILES['imageUpload']['name']);
/* mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) ;
mysql_select_db("Database_Name") or die(mysql_error()) ;
*/
//Writes the information to the database
$sql_insert = "INSERT into `Cars`
(`CarImage`)
VALUES
('$path')
";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
... ?>
答案 0 :(得分:2)
您的创建声明错误
您在表格中使用了两次相同的列名:CurrColour
答案 1 :(得分:0)
重复列CurrColumn然后你错过了a)在语句的最后
答案 2 :(得分:0)
您有以下列的两个条目
`CurrColour` varchar(50) collate latin1_general_ci NOT NULL default '',