由于某种原因,我需要把数据从4.1.20导入到3.23.54 版本中.中文就变成了乱码,我用phpmyadmin操作的,我在4.1.20版本中设置的是utf8_general_ci。请问各位高手有没有好的解决办法??那位高手能提供一些关于数据导入乱码问题的资料或信息,定不胜感激!!!再次感谢!

解决方案 »

  1.   

    自己写代码试试
    <?PHP
    require_once ("includes/config.inc.php");//注意mysql数据库类!!??????
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="utf-8" />
    <title>广州赢动科技</title>
    <style>
    <!--
    body {
    font-size: 13px;
    margin:10px;
    font-family:Arial, Helvetica, sans-serif;
    }* {
    word-wrap:break-word; 
    word-break:break-all;
    white-space:normal;
    }img,form {
            border:0;
    margin:0;
    padding:0;
    }td,div,inupt,select,textarea {
    font-size: 13px;
    }p {margin:0;padding:0;line-height:150%;}
    //-->
    </style>
    </head>
    <body>
    <a href="http://hi.baidu.com/lael80/">博客</a> 
    <?PHP$btn1 = $_POST["btn1"];if(!empty($btn1) && !empty($_POST["table1"]) && !empty($_POST["table2"])){ $num_field = 0;

    $access = odbc_connect("DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\root\\asp\\carsclub\\data\\fy2sc.mdb"
    ,"",
    "",
    SQL_CUR_USE_ODBC);
    $query = odbc_do($access , "select * from ".$_POST["table1"]);
    $num_field = max(odbc_num_fields($query), $num_field);
    $table1 = "";
    for($i = 0; $i < odbc_num_fields($query); $i ++){ 
    $table1 .= "<option value=\"".@odbc_field_name($query,$i+1)."\">".@odbc_field_name($query,$i+1)."</option>\r\n";
    }
    odbc_close($access);
    $query = $db->query("select * from ".$_POST["table2"]);
    $num_field = max($db->num_fields($query), $num_field);
    $table2 = "";
    for($i = 0; $i < $db->num_fields($query); $i ++){ 
    $table2 .= "<option value=\"".$db->field_name($query,$i)."\">".$db->field_name($query,$i)."</option>\r\n";
    }
    }$btn2 = $_POST["btn2"];if(!empty($btn2)){
    $clear = $_POST["clear"];

    if($clear == "Y"){
    $db->query("TRUNCATE TABLE ".$_POST["table2"]);
    }

    $field1 = $_POST["field1"];
    $field2 = $_POST["field2"];
    $value = $_POST["value"];

    if(!empty($field2)){
    $access = odbc_connect("DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\root\\asp\\carsclub\\data\\fy2sc.mdb"
    ,"",
    "",
    SQL_CUR_USE_ODBC);
    $query = odbc_do($access , "select * from ".$_POST["table1"]);

    while($row = odbc_fetch_array($query)){
    for($i = 0; $i < count($field2); $i ++){
    if(!empty($field1[$i])){
    $row[$field1[$i]] = iconv("gb2312", "utf-8", $row[$field1[$i]]);
    if(!empty($value[$i])){
    if(strpos($value[$i], "format:time()") === 0){
    $insert[$field2[$i]] = format_date_time($row[$field1[$i]]);
    }else{
    $insert[$field2[$i]] = $row[$field1[$i]];
    }
    }else{
    $insert[$field2[$i]] = $row[$field1[$i]];
    }
    }else if(!empty($value[$i])){
    if(strpos($value[$i], "eval:") === 0){
    call_func($insert[$field2[$i]], substr($value[$i], 5));
    }else{
    $insert[$field2[$i]] = $value[$i];
    }
    }
    }
    ////
    if($row["classid"] == 1)$insert["groupid"] = 2;
    if($row["classid"] == 2)$insert["groupid"] = 4;
    if($row["classid"] == 4)$insert["groupid"] = 3;
    if($row["classid"] != 1 && $row["classid"] != 2 && $row["classid"] != 4)$insert["groupid"] = 1;
    ////
    if(!empty($insert)){
    $db->insert($_POST["table2"], $insert);
    }
    }
    odbc_close($access);
    }
    }function call_func(&$result, $params){
    switch($params){
    case "time()":
    $result = time();
    break;
    default:
    }
    }
    ?>
    <form method="post" action="">
    <table border="1" cellspacing="5" cellpadding="0">
      <tr>
        <td><input name="table1" type="text" id="table1" value="<?PHP echo $_POST["table1"];?>"></td>
        <td><input name="table2" type="text" id="table2" value="<?PHP echo $_POST["table2"];?>"></td>
        <td><input name="clear" type="checkbox" id="clear" value="Y">
          清空目标表</td>
      </tr>
      <tr>
        <td colspan="3"><input name="btn1" type="submit" id="btn1" value=" 确定 "></td>
        </tr>
    <?PHP
    for($i = 0; $i < $num_field; $i ++){
    ?>
      <tr>
        <td><select name="field1[]" id="field1[]">
          <option value="">请选择字段</option>
      <?PHP echo $table1;?>
        </select>    </td>
        <td><select name="field2[]" id="field2[]">
          <option vlaue="">请选择字段</option>
      <?PHP echo $table2;?>
        </select>    </td>
        <td><input name="value[]" type="text" id="value[]" size="35"></td>
      </tr>
    <?PHP
    }
    ?>
      <tr>
        <td colspan="3"><input name="btn2" type="submit" id="btn2" value=" 导入 "></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    好象主体不对,我是用phpmyadmin操作的!