When trying to do a simple insert in PHP to MySQL database, a value of '.5' is entered into the hours variable and is being ignored and set to 0 in the database. I've tried with the db datatype set to float or decimal. Neither work.
Here is my insert code:
$sql ="INSERT INTO timecarddetails (timecardId, tdate, hours, ot, ticketNumber, km, details)
VALUES (?,?,?,?,?,?,?)";
$stmt = $conn->prepare($sql);
if($stmt === false){
trigger_error('Wrong SQL: ' .$sql. ' Error: ' . $conn->error, E_USER_ERROR);
}
$stmt->bind_param('isiisis',$tcId,$JOBDATE[$key],$HOURS[$key],$OT[$key],$TICKET[$key],$KM[$key],$DETAILS[$key]);
$stmt->execute();
When I do a print of the sql statement it comes out like this:
INSERT INTO timecarddetails (timecardId, tdate, hours, ot, ticketNumber, km, details) VALUES (24,2019-11-04,.5, , 2019450202,,Dispatched ticket)
Is there anything wrong with my syntax? If you need any further information, please let me know. Thanks in advance for helping!
