Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

MySQL Syntax Error - INSERT INTO

$
0
0

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?

 

 

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 'Range, Percent, Sleep) VALUES (2013-12-01 10:15:07, 189.18, 82, 1)' at line 1

 

MySQL table is configured as follows:

 

 

Date
timestamp
CURRENT_TIMESTAMP

 

Range
decimal(5,2)
 
Percent
tinyint(3)
 
Sleep
tinyint(1)
0

 

Any ideas?


Viewing all articles
Browse latest Browse all 13200

Trending Articles