Following is my table structure:
CREATE TABLE `order` (
`ID` BIGINT(20) NOT NULL AUTO_INCREMENT,
`RenterRole_ID` INT(11) NULL DEFAULT NULL,
`CreationTime` DATETIME NULL DEFAULT NULL,
`BeginRentingDate` DATETIME NULL DEFAULT NULL,
`EndRentingDate` DATETIME NULL DEFAULT NULL,
`TripStartDate` DATETIME NULL DEFAULT NULL,
`TripEndDate` DATETIME NULL DEFAULT NULL,
`DeliveryDetails` VARCHAR(255) NULL DEFAULT NULL,
`ReturningDetails` VARCHAR(255) NULL DEFAULT NULL,
`SpareSpotBatteries` INT(11) NULL DEFAULT NULL,
`spareInReach15Batteries` INT(11) NULL DEFAULT NULL,
`Remarks` TEXT NULL,
`OrdersCenter_ID` INT(11) NOT NULL DEFAULT '100',
`HashedCCNumber` VARCHAR(255) NULL DEFAULT NULL,
`CCExpiration` DATETIME NULL DEFAULT NULL,
`CCHolderName` VARCHAR(255) NULL DEFAULT NULL,
`CreatingController` VARCHAR(255) NULL DEFAULT NULL,
`Debug` BIT(1) NOT NULL DEFAULT b'0',
`TravelInsuranceOffer` BIT(1) NULL DEFAULT b'0',
`DeviceInsurance` BIT(1) NULL DEFAULT b'0',
`OrdersCenterRemarks` TEXT NULL,
`Rivhit` VARCHAR(100) NULL DEFAULT NULL,
`Invoice` VARCHAR(100) NULL DEFAULT NULL,
`Payment` VARCHAR(200) NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
INDEX `FK_OrderOrdersCenter_idx` (`OrdersCenter_ID`),
INDEX `FK_OrderRenterRole_idx` (`RenterRole_ID`),
CONSTRAINT `FK_OrderOrdersCenter` FOREIGN KEY (`OrdersCenter_ID`) REFERENCES `orderscenter` (`ID`),
CONSTRAINT `FK_OrderRenterRole` FOREIGN KEY (`RenterRole_ID`) REFERENCES `renter_role` (`ID`)
)
when i try to INSERT data by following code:
$query = "INSERT INTO order (RenterRole_ID) VALUES (?)";
$stmt = $mysqli->prepare($query);
if (false === $stmt) {
echo 'prepare() failed: ' . htmlspecialchars($mysqli->error);
die();
}
$stmt->bind_param('i',$newRenterId);
if (false === $bind) {
echo 'bind_param() failed: ' . htmlspecialchars($stmt->error);
die();
}
$stmt->execute();
$newOrderId = $stmt->insert_id;
$stmt->close();
cause following error:
prepare() failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (RenterRole_ID) VALUES (?)' at line 1
in other table INSERT code is working good only order table having issues.