出于某种原因,我无法在我的数据库上进行简单的插入操作,而且我没有收到任何错误。
我希望这是我遗失的明显事物。我可以在命令行上添加表,而不是从php。
表正在使用InnoDB引擎。我对php& MySql所以我希望它只是一个简单的错误。
mysqli_autocommit($con,TRUE);
echo "<BR>TIME TO ENTER THE DATA TO THE DB</BR>";
$successful = TRUE;
//Adding data to the TRIP table
$q = "INSERT INTO Trip (Date, Distance, Duration, Route, Conditions, Weather, Description, Title)
VALUES ('$date', '$distance', '$duration', '$route', '$conditions', '$weather', '$description', '$tripTitle')";
$res = mysqli_query($con, $q );
if($res === false){
$successful = FALSE;
echo "$successful = FALSE after adding data to trip table<BR>";
}
else{
echo "<BR>Trip data entered sucessfully<BR>";
//$tripID = mysql_insert_id();
//echo "Trip ID = ".$tripID;
}
echo "<BR>Made it to the bottom of the code</BR>";
以下是表格属性。
CREATE TABLE `Trip` (
`idTrip` int(11) NOT NULL AUTO_INCREMENT,
`Distance` float DEFAULT NULL,
`Duration` time DEFAULT NULL,
`Route` longtext,
`Conditions` longtext,
`Weather` longtext,
`Description` longtext,
`Date` date NOT NULL,
`Last Edited` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
`Created` datetime NOT NULL,
`Title` longtext NOT NULL,
PRIMARY KEY (`idTrip`),
UNIQUE KEY `idTrip_UNIQUE` (`idTrip`),
UNIQUE KEY `date_unique` (`Date`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
任何帮助都将不胜感激。
答案 0 :(得分:1)
不是吗
$q = "INSERT INTO Trip (Date, Distance, Duration, Route, Conditions, Weather, Description, Title)
VALUES ('" . $date . "', '" . $distance . "', '" . $duration . "', '" . $route . "', '" . $conditions . "', '" . $weather . "', '" . $description . "', '" . $tripTitle . "')";
尝试echo $ q;
然后将查询复制到MySQL CLI中,以检查是否存在错误,如果您不想添加mysqli_error输出。