解决方案 »

  1.   

    程序编码是什么?换成和phpmyadmin编码一样的
      

  2.   

    程序编码是utf-8 ,phpMyAdmin也是utf-8 
    度娘说  要在获取数据库连接时update (set names utf_8)
    我加上后,运行报错 Fatal error: Uncaught exception 'DB_Exception' with message '更新失败:Unknown character set: 'utf''
      

  3.   


    ('set names utf8')
    不是
    (‘set names utf_8')
      

  4.   

    嗯,用utf8试了,这个问题搞定了
    现在剩下timestamp问题:time()函数不行,我试了date("Y-m-d h:i:s")
    问题是写入的时间为:
    array(3) { ["org_id"]=> string(1) "1" ["org_name"]=> string(9) "上海市" ["open_time"]=> string(19) "2014-08-23 18:35:18" } 
    array(3) { ["org_id"]=> string(1) "2" ["org_name"]=> string(20) "北京市" ["open_time"]=> string(19) "0000-00-00 00:00:00" } 
    array(3) { ["org_id"]=> string(1) "3" ["org_name"]=> string(9) "重庆市" ["open_time"]=> string(19) "0000-00-00 00:00:00" } 
    array(3) { ["org_id"]=> string(1) "4" ["org_name"]=> string(9) "天津市" ["open_time"]=> string(19) "2014-08-23 12:00:31" } 
    array(3) { ["org_id"]=> string(1) "5" ["org_name"]=> string(9) "河北省" ["open_time"]=> string(19) "2014-08-23 12:02:34" } 
    比正常时间慢了8小时,不知道是不是时区的问题,应该怎么设置?
      

  5.   

    $org = array(
    "org_id" => 2,
    "org_name" => "北京市",
    "open_time" => 'now()'
    );
    用数据库的时间函数较好你 date 得到的时间不对,是因为你的树区没有设置好
      

  6.   

    我在获取数据库连接的地方加上了date_default_timezone_set('PRC');
    写入的时间是["open_time"]=> string(19) "2014-08-23 08:11:27" ,貌似不是24小时制了
    刚试了你的"open_time" => 'now()' 得到的是["open_time"]=> string(19) "0000-00-00 00:00:00" ,我的写入参数都用addslashes转义过,不知道是不是这个问题
      

  7.   

    php当中没有now()函数
    now()  等价 date("Y-m-d H:i:s" );