PHP to send mobile Mas SMS garbled solution method

Source: Internet
Author: User

The project needs to use the Mobile Agent Mas SMS Interface development, but the manufacturers to provide the development package without PHP, can only use the DB interface, direct operation of MySQL. But after the text message sent, the mobile phone received the text message is really garbled, pondering for a long time, the approximate judgment should be the problem of character encoding. Continue to study and experiment in this direction, and finally find out the reason. 1. Log into the MySQL database of the MAS machine,
Use command: Show variables like "%char%";
To view the character encoding of the MySQL database:

2 . PHP is used as follows: mysql_connect (' ip:3306 ', ' user ', ' pwd ');
mysql_select_db (' Mas ');
mysql_query ("Set names latin1;");
mysql_query (mb_convert_encoding ("INSERT into API_MT_DB01 (mobiles,content) VALUES ('". $mobiles. "', '". $content. "');" , "GB2312", "UTF-8"));
Where set names Latin1 is equivalent to
SET character_set_client = latin1; SET character_set_results = latin1; SET character_set_connection = latin1;
3, the character encoding in the project is UTF-8, the running environment is Windows 2008, its character encoding is GB2312,
Because the latin1 and UTF8 character sets are incompatible, the conversion is irreversible, so you have to turn UTF8 into gb2312, then turn GB2312 into Latin1
so the information input path: app->os->client->connection->mysql, encoding and encoding conversion process utf8->gb2312->latin1->latin1-> Latin1

PHP to send mobile Mas SMS garbled solution method

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.