For some reason I can't get a simple insert to work on my database and I'm getting no errors.
I'm hoping it is something obvious that I am missing. I can add to the table on the command line, just not from php.
Table is using the InnoDB engine. I'm fairly new to php & MySql so I'm hoping it's just a simple mistake.
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>";
Below is the table properties.
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;
Any help would be appreciated.
"); it just shows up blank. – David Jack Jul 05 '16 at 14:08