我可以从xml读到一个时间:1235716200000
似乎用的date的时候需要除1000
所以我用$start_time = $post->getElementsByTagName("StartTime")->item(0)->nodeValue/1000;然后$query="INSERT INTO `test` (`start_time`) VALUES (".$start_time.")";
结果报错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 '06:30:00)' at line 1加两个引号$query="INSERT INTO `test`(`start_time`) VALUES ('".$start_time."')";
也报错Incorrect datetime value: '1970-01-01 00:00:00' for column 'start_time' at row 1求教达人,这是什么问题?原因是什么,应该怎么正确插入

解决方案 »

  1.   

    去掉点 .要不把sql语句输出来看下
      

  2.   

    $result = $db->query($query);
    if (!$result){
    echo $query."\n";
    echo $db->error.$discover.'<br />';
    }else{
    //echo $Title."added.<br />";
    }
      

  3.   

    php变量在双引号中能直接使
    $query="INSERT INTO `test` (start_time) VALUES ($start_time)";
    这样子应该可以吧 
      

  4.   

    不行,报错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 '06:30:00)' at line 1
      

  5.   

    echo "INSERT INTO `test` (start_time) VALUES ($start_time)"; 
      

  6.   

    数据库的start_time字段类型不匹配,改为int(10)即可
      

  7.   

    头疼的错误,方法是对的,但是xml中间的某几个节点的数据不对,才报的这个错,感谢大家