0
votes

I'm getting the following error while running the SQL query given below

'Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005?T in SQLExecDirect in D:\xampp\htdocs\fypphp\functions.php on line 543'

INSERT INTO vehicle_log
(modem_ID, longitude, latitude, sattelite_strength, [timestamp], speed, Heading, Altitude, ReportID, Input, Output)
values
('$modem_id', '$longitude', '$latitude', '$satelite_str', '$timestamp', '$speed', '$heading', '$altitude', '$report_id', '$input', '$output')
4

4 Answers

1
votes

You might need to convert one of your variables. What are your column types? Also try putting in some sample/test data to narrow down the problem.

0
votes

Are any of the fields numeric, like for example the ReportID? Then you should remove the apostrophes around the value.

Edit:
With latitude, longitude and sattelite strength as numeric, you should have:

INSERT INTO vehicle_log
(modem_ID, longitude, latitude, sattelite_strength, [timestamp], speed, Heading, Altitude, ReportID, Input, Output)
values
('$modem_id', $longitude, $latitude, $satelite_str, '$timestamp', '$speed', '$heading', '$altitude', '$report_id', '$input', '$output')

If timestamp is a date, you should have:

INSERT INTO vehicle_log
(modem_ID, longitude, latitude, sattelite_strength, [timestamp], speed, Heading, Altitude, ReportID, Input, Output)
values
('$modem_id', $longitude, $latitude, $satelite_str, #$timestamp#, '$speed', '$heading', '$altitude', '$report_id', '$input', '$output')
0
votes

What are the datatypes of the variables and the datatypes of the fields in the table?

Incidentally, I'd fix the column with the word sattelite in it because of the misspelling if this is new development. This will drive you crazy over the years.

0
votes

You are trying to add $modem_id and it is probably auto-increment? Leave the $mode_id out, it will add it automatica;ly.