About transcoding Issues

Source: Internet
Author: User
Import 503-9256962-4382268 Failure-1
You have a error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' 054-246-0787 ', ' JPS0001 ', ' 0243-BK ', ' iphone 4 with arm? (black) ', ' 1 ', '??? ' at line 1

I have done transcoding also reported above error, my transcoding function:
$recipient _name=mb_convert_encoding (Addslashes ($u [+]), ' UTF-8 ', ' Utf-8,sjis-win,eucjp-win ');



Echo Base64_encode ($u [16]) Result: MGIRG4XC

I output transcoding after the result is right: "?? GUI ", but do not know to write to the database will be error, I found that only contains" GUI "will write to the database failed.

Is there any way to solve this problem??


Reply to discussion (solution)

database field encoding is not supported

Gu gui \
?? Kyu

I re-output, the name with the "\", is not this reason?? How can i solve it?

$s = base64_decode (' mgirg4xc '); Echo ' character set ', mb_detect_encoding ($s, ' utf-8,sjis-win,eucjp-win '), '
'; Echo ' 16 Inside code ', Bin2Hex ($s), '
' Echo ' utf-8 ', $t = mb_convert_encoding ($s, ' utf-8 ', ' Utf-8,sjis-win,eucjp-win '), '
'; Echo ' 16 Inside code ', Bin2Hex ($t);

Character Set Jis-win
16 binary inside Code 986891838c 5c This 5c is \ 's 16 in-system code
Utf-8?? Kyu
16 Binary inside Code E9B7B2E5B7A3E59CAD

So you need
$recipient _name=mb_convert_encoding ($u [+], ' UTF-8 ', ' Utf-8,sjis-win,eucjp-win ');
Instead of
$recipient _name=mb_convert_encoding (Addslashes ($u [+]), ' UTF-8 ', ' Utf-8,sjis-win,eucjp-win ');
That can't be escaped with addslashes.

Escape ' requires Str_replace ("'", "\ '", $s)

Xuzuning greatly:
Do not escape, but there is a question to ask, because I inserted the content is a lot of countries, if not escaped, do not know which country's name contains some special, do not escape the words may be the same as write failure, excuse me, is there a way to solve this situation?

Transcode first, then escape

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.