MYSQL 4.1 中+MYSQL-FRONT 3.2;    
    $sql="update staff set staff_name=? "; 
    此处输出 $staff_name 为中文,如 小王; 
    $ret=$this->execute($sql, $staff_name); 
    function execute($query, $data, $offset=0, $numRows = 0xFFFFFFFF) 
    { 
        if ($numRows == -1) 
        { 
            $numRows = 0xFFFFFFFF; 
        } 
        
        $pieces = explode(" ", $query); 
        if (strToLower($pieces[0]) == "select"){ 
            $query .= " limit ?, ?"; 
            $data[] = $offset; 
            $data[] = $numRows; 
        }    
      $stmt = $this->db_conn->prepare($query); 
        if (DB::isError($stmt)) 
        { 
            $this->halt("execute:repare", $stmt->getDebugInfo(), $stmt->getMessage()); 
        }        
      $this->db_result = $this->db_conn->execute($stmt, $data); 
        if (DB::isError($this->db_result)) 
        { 
            $this->halt("execute:execute", $this->db_result->getDebugInfo(), $this->db_result->getMessage()); 
        } 
        return $this->db_result; 
    } 
staff_name 进入数据库中 不是中文,是个XX符号,大家帮我看看 execute这个函数转码了吗? 
页面显示却是中文,可我想直接 在DB中执行SQL:update staff set staff_name='小李';页面显示出来的就是??乱码了, 
我不知怎么回事?

解决方案 »

  1.   

    show variables like 'char%'; 
    贴结果
      

  2.   

    在你的mysql命令工具中设置一下字符集。set names 'gb2312';   //注意,设置为你数据表的相同字符集。 show full columns for yourTable看一下字段的字符集设置
      

  3.   

    修改C:\Program Files\MySQL\MySQL Server 5.0\my.ini
    修改部分如下:
    [mysql]
    default-character-set=gb2312
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="C:/Program Files/MySQL/MySQL Server 5.0/"#Path to the database root
    datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"# The default character set that will be used when a new schema or table is
    # created and no character set is defined
    default-character-set=utf8# The default storage engine that will be used when create new tables when
    default-storage-engine=INNODB# Set the SQL mode to strict
    # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
      

  4.   

    http://blog.csdn.net/jaopen/articles/1933369.aspx?P_AVPASS=PHDGBITAVPASST