【问题标题】:Sql error while running query data type mismatch in criteria expression在条件表达式中运行查询数据类型不匹配时出现 Sql 错误
【发布时间】:2009-03-10 17:04:19
【问题描述】:

运行下面给出的 SQL 查询时出现以下错误

'警告:odbc_exec() [function.odbc-exec]:SQL 错误: [微软][ODBC微软访问 驱动程序] 标准中的数据类型不匹配 表达式,SQL 状态 22005?T 在 SQLExecDirect 在 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')

【问题讨论】:

    标签: php sql


    【解决方案1】:

    您可能需要转换其中一个变量。您的列类型是什么?还可以尝试放入一些样本/测试数据来缩小问题范围。

    【讨论】:

      【解决方案2】:

      是否有任何字段为数字,例如 ReportID?然后你应该删除值周围的撇号。

      编辑:
      以纬度、经度和卫星强度为数字,您应该:

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

      如果时间戳是一个日期,你应该有:

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

      【讨论】:

      • 试过还是不行只有纬度、经度和卫星强度是数字
      【解决方案3】:

      表中变量的数据类型和字段的数据类型是什么?

      顺便说一句,如果这是新的发展,我会修正其中包含卫星一词的列,因为拼写错误。多年来,这会让你发疯。

      【讨论】:

        【解决方案4】:

        您正在尝试添加$modem_id,它可能是自动递增的?留下$mode_id,它会自动添加它。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多