开发者

mysql 4.x -> 5.x upgrade problem

im upgrading from mysql 4.x to 5 version.

in my php source i have following source which working well on mysql 4.x version.

but if on mysql 5.x version, it not working.

i think following part of my php source some suspect which cause some problem.

if anyone help me much appreate

  <? 
    include('_connect_site_01.php');
    $DB = new MySQL;
    $DB->DBconnect();

    if(!$_GET[partner]) $_GET[partner] = "root";
    if(!$_GET[spcode]) $_GET[spcode] = "health";
    $date  = date("Y-m-d");
    $Query = "SELECT date FROM partner_count WHERE partner='$_GET[partner]' AND date='$date'"; 
    $DB->开发者_StackOverflow中文版ExecSql($Query); $row = $DB->Fetch();

    if($row[date] == NULL)
    {
        $Insert = "INSERT INTO partner_count (id,partner, date, hit) VALUES('','$_GET[partner]','$date','1')";
        $DB->ExecSql($Insert);
    }
    else
    {
        $Update = "UPDATE partner_count SET hit= hit+1 WHERE partner='$_GET[partner]'";
        $DB->ExecSql($Update);
    }
  ?>


You have to set colation and charset after you connect

SET NAMES koi8r;
SET CHARACTER SET koi8r;
SET collation_connection = koi8r_general_ci;

so after $DB->DBconnect(); you should run:

$DB->ExecSql("SET NAMES koi8r;");
$DB->ExecSql("SET CHARACTER SET koi8r;");
$DB->ExecSql("SET collation_connection = koi8r_general_ci;");


@cichy's answer is not clear. For mysql >=5.0 you should use mysql_set_charset() and not the queries that he said.

Also, the data could be broken when you migrated to new mysql. You have not described how that migration was performed, so the root issue can be much more complex than just proper usage of mysql_set_charset().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜