简体   繁体   中英

utf-8 cannot insert to mysql after connection to mssql

first of all , I connected two database -mssql & mysql- .

 global $link,$link_voip;
    $link = mssql_connect('A', 'B', 'C');
    mssql_select_db('D', $link);
    if (!$link) {
        die('Something went wrong while connecting to MSSQL');
    }
    $link_voip = mysql_connect('E','F','G') or die("err");

mysql_query("SET NAMES 'utf8'", $link_voip);
mysql_query("SET CHARACTER SET 'utf8'", $link_voip);
mysql_query("SET character_set_connection = 'utf8'", $link_voip);
mysql_select_db('voip', $link_voip);

I want to update a row on mysql database with mssql's information: I get information correctly , but mysql database cannot insert utf-8 (persian language).
I'm working with phpmyadmin ,I used to try:
1- change collation to utf_general_ci
2- add

mysql_query("SET NAMES 'utf8'", $link_voip);
mysql_query("SET CHARACTER SET 'utf8'", $link_voip);

before query.
3-add N before variable that may be changed.

    $q="UPDATE cc_card SET  firstname=N'$fname' , lastname=N'$lname',phone='$phone',credit='$credit' 
    WHERE id='$id'";

but still it doesn't work.

1- in mssql :
1-1. check table type is nvarchar
1-2. convert to varbinary (CONVERT(varbinary(MAX),tblname)
1-3. use bin2hex
1-3. use chr(hexdec$varibale)
1-5. use iconv
2- in mysql : use N before variable for update/insert in database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM