I've banged my head enough trying to figure out this problem and have given up.
I've inserted data into an SQL DB before without any problems. Not sure what's going on here. This is my code:
$charge = function_read("vehicles/" . $status[0]['id'] . "/command/charge_state");
$miles = mysqli_real_escape_string($con, $charge['battery_range']);
$battery_level = mysqli_real_escape_string($con, $charge['battery_level']);
mysqli_query($con,"INSERT INTO battery (Date, Range, Percent, Sleep) VALUES ($date, $miles, $battery_level, 1)");
echo $con->error;
This is the error message (completely worthless, IMHO). Could it be any less descriptive?
MySQL table is configured as follows:
Date timestamp CURRENT_TIMESTAMP
Range decimal(5,2)
Percent tinyint(3)
Sleep tinyint(1) 0
Any ideas?