tags:

views:

43

answers:

2

hello All

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->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);
    }
  ?>
A: 

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
Your answer is not correct, i've added better one.
zerkms
this code is awfully redundant. actually only first query is enough
Col. Shrapnel
@Col. Shrapnel: the more lines - the better code.
zerkms
i was attached full source following pastebin site http://pastebin.com/3Sg7SyWV and also added $DB->ExecSql("SET NAMES koi8r;");$DB->ExecSql("SET CHARACTER SET koi8r;");$DB->ExecSql("SET collation_connection = koi8r_general_ci;");but it can't send form data to other page.
paul
A: 

@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().

zerkms
This only applies if the OP is using the mysql_*() function family (he doesn't say).
Álvaro G. Vicario
@Álvaro G. Vicario: then he should use the function that is total synonym for `mysql_set_charset()` in his client library. Other implementations are ideologically wrong and can be vulnerable.
zerkms