简体   繁体   English

运行条件表达式中的查询数据类型不匹配时出现 Sql 错误

[英]Sql error while running query data type mismatch in criteria expression

I'm getting the following error while running the SQL query given below运行下面给出的 SQL 查询时出现以下错误

'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' '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 上线 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')

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.还可以尝试放入一些样本/测试数据来缩小问题范围。

You are trying to add $modem_id and it is probably auto-increment?您正在尝试添加$modem_id并且它可能是自动增量的? Leave the $mode_id out, it will add it automatica;ly.保留$mode_id ,它会自动添加它。

Are any of the fields numeric, like for example the ReportID?是否有任何字段为数字,例如 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')

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.顺便说一句,如果这是新的发展,我会修复带有 sattelite 一词的专栏,因为拼写错误。 This will drive you crazy over the years.多年来,这会让你发疯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM