PHPÓëMySQL¿ª·¢ÖеÄ×Ö·û±àÂëÎÊÌâ
Ò»£®¹ØÓÚMySQLÊý¾Ý¿â·þÎñÆ÷
MySQL·þÎñÆ÷µÄĬÈϱàÂëÊÇLatin1£¬²»Ö§³ÖÖÐÎÄ£¬ÄÇôÈçºÎÐÞ¸ÄMySQLµÄĬÈϱàÂëÄØ£¬ÏÂÃæÒÔUTF-8ΪÀýÀ´ËµÃ÷¡£
1¡¢ÖÐÖ¹MySQL·þÎñ£¨bin/mysqladmin -u root shutdown£©
2¡¢ÔÚ/etc/ÏÂÕÒµ½my.cnf£¬Èç¹ûûÓоͰÑMySQLµÄ°²×°Ä¿Â¼ÏµÄsupport-filesĿ¼ÏµÄmy-medium.cnf¸´ÖƵ½/etc/ϲ¢¸ÄÃûΪmy.cnf¼´¿É
3¡¢´ò¿ªmy.cnfÒÔºó£¬ÔÚ[client]ºÍ[mysqld]ÏÂÃæ¾ù¼ÓÉÏdefault-character-set=utf8£¬±£´æ²¢¹Ø±Õ
4¡¢Æô¶¯MySQL·þÎñ£¨bin/mysqld_safe &£©·Ç³£¼òµ¥£¬ÕâÑùµÄÐÞ¸ÄÒ»ÀÍÓÀÒÝ£¬½ñºóMySQLÒ»ÇÐÏà¹ØµÄĬÈϱàÂë¾ùΪUTF-8ÁË£¬´´½¨Ð±í¸ñµÄʱºòÎÞÐèÔÙ´ÎÉèÖá£
¶þ£®PHP³ÌÐòÉè¼ÆʱҪ¿¼ÂǵÄ×Ö·û±àÂëÎÊÌâ
Ò»°ãÀ´Ëµ£¬ÂÒÂëµÄ³öÏÖÓÐ2ÖÖÔÒò£¬Ê×ÏÈÊÇÓÉÓÚ±àÂë(charset)ÉèÖôíÎ󣬵¼ÖÂä¯ÀÀÆ÷ÒÔ´íÎóµÄ±àÂëÀ´½âÎö£¬´Ó¶ø³öÏÖÁËÂúÆÁÂÒÆß°ËÔãµÄ“ÌìÊ锣¬ Æä´ÎÊÇÎļþ±»ÒÔ´íÎóµÄ±àÂë´ò¿ª£¬È»ºó±£´æ£¬±ÈÈçÒ»¸öÎı¾ÎļþÔÏÈÊÇGB2312±àÂëµÄ£¬È´ÒÔUTF-8±àÂë´ò¿ªÔÙ±£´æ¡£Òª½â¾öÉÏÊöÂÒÂëÎÊÌ⣬Ê×ÏÈÐèÒªÖªµÀ ¿ª·¢ÖÐÄÄЩ»·½ÚÉæ¼°µ½Á˱àÂ룺
1¡¢Îļþ±àÂ룺ָµÄÊÇÒ³ÃæÎļþ(.html,.phpµÈ)±¾ÉíÊÇ ÒÔºÎÖÖ±àÂëÀ´±£´æµÄ¡£¼Çʱ¾ºÍDreamweaverÔÚ´ò¿ªÒ³Ãæʱºò»á×Ô¶¯Ê¶±ðÎļþ±àÂëÒò¶ø²»Ì«»á³öÎÊÌâ¡£¶øZendStudioÈ´²»»á×Ô¶¯Ê¶±ð±àÂ룬Ëü Ö»»á¸ù¾ÝÊ×Ñ¡ÏîµÄÅäÖù̶¨ÒÔijÖÖ±àÂë´ò¿ªÎļþ£¬Èç¹û¹¤×÷ʱºòÒ»²»×¢Ò⣬ÓôíÎó±àÂë´ò¿ªÎļþ£¬×öÁËÐÞ¸ÄÖ®ºóÒ»±£´æ£¬ÂÒÂë¾Í³öÏÖÁË£¨ÎÒÉîÓÐÌå»á£©¡£
2¡¢Ò³ÃæÉêÃ÷±àÂ룺ÔÚHTML´úÂëHEADÀïÃ棬¿ÉÒÔ ÓÃ<meta http-equiv="Content-Type" content="text/html; charset="XXX" />À´¸æËßä¯ÀÀÆ÷ÍøÒ³²ÉÓÃÁËʲô±àÂ룬ĿǰÖÐÎÄÍøÕ¾¿ª·¢ÖÐXXXÖ÷ÒªÓõÄÊÇGB2312ºÍUTF-8Á½ÖÖ±àÂë¡£
3¡¢Êý¾Ý¿âÁ¬½Ó±àÂ룺ָµÄÊǽøÐÐÊý¾Ý¿â²Ù×÷ʱºòÒÔÄÄÖÖ±àÂëÓëÊý¾Ý¿â´«ÊäÊý¾Ý£¬ÕâÀïÐèҪעÒâµÄÊDz»ÒªÓëÊý¾Ý¿â±¾ÉíµÄ±àÂë»ìÏý£¬±ÈÈçMySQLÄÚ²¿Ä¬ÈÏÊÇlatin1±àÂ룬Ҳ¾ÍÊÇ˵MysqlÊÇÒÔlatin1±àÂëÀ´´æ´¢Êý¾Ý£¬ÒÔÆäËû±àÂë´«Êä¸øMysqlµÄÊý¾Ý»á±»×ª»»³Élatin1±àÂë¡£
ÖªµÀÁËWEB¿ª·¢ÖÐÄÄЩµØ·½Éæ¼°µ½Á˱àÂ룬Ҳ¾ÍÖªµÀÁËÂÒÂë²úÉúµÄÔÒò£ºÉÏÊö3Ïî±àÂëÉèÖò»Ò»Ö£¬ÓÉÓÚ¸÷ÖÖ±àÂë¾ø´ó²¿·ÖÊǼæÈÝASCIIµÄ£¬ËùÒÔÓ¢ÎÄ·ûºÅ²»»á³öÏÖ£¬ÖÐÎľ͵¹Ã¹ÁË¡£ÏÂÃæÊÇһЩ³£¼ûµÄ´íÎóÇé¿öÓë½â¾ö£º
1¡¢Êý¾Ý¿â²ÉÓÃUTF8±àÂ룬¶øÒ³ÃæÉêÃ÷±àÂëÊÇGB2312£¬ÕâÊÇ×î³£¼ûµÄ²úÉúÂÒÂëµÄÔÒò¡£ÕâʱºòÔÚPHP½Å±¾ÀïÃæÖ±½ÓSELECTÊý¾Ý³öÀ´µÄ¾ÍÊÇÂÒÂ룬ÐèÒªÔÚ²éѯǰÏÈʹÓãº
mysql_query("SET NAMES GBK");
À´É趨M
Ïà¹ØÎĵµ£º
ת×Ô http://www.supidea.com/post/mysql_design_database.aspx
MySQLÊý¾Ý¿âÉè¼ÆÔÔò
MySQL¶ÔÓÚ³ÉΪһ¸ö·Ç³£¿ìËÙµÄÊý¾Ý¿â·þÎñÆ÷ÓÐ×ŵ±Ö®ÎÞÀ¢µÄÃûÉù£¬ËüÒ²·Ç³£ÈÝÒ×ÉèÖúÍʹÓá£Ëæ×ÅËü×÷ΪÍøÕ¾ºó¶ËÊý¾Ý¿âµÃÉùÍûÈÕÔö£¬ÆäЧ¹ûÔÚÈ¥Ä꿪ʼÓÐÃ÷ ÏÔÌá¸ß¡£µ«ÊǺܶàMySQLÓû§¸ü¶àµØÖªµÀÈçºÎ´´½¨Ò»¸öÊý¾Ý¿â²¢±àд¶ÔËüµÄ²éѯ¡£¾ÍÏñ³ÉÇ ......
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%
//Á¬½ÓÊý¾Ý¿â
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection connection= java.sql.DriverManager.getConnection("jdbc:mysql://localhost/dangyuan","root", ......
$zip = new ZipArchive;
$res = $zip->open(UPLOAD_DIR.'/attach.zip', ZIPARCHIVE::CREATE);
if ($res === true) {
foreach ($fileinfo as $value) {
$zip->addFile(UPLOAD_DIR.'/'.$value['SA ......
½¨Õ¾³ÌÐòÊÇÕ¾³¤ÔËÓªÍøÕ¾µÄ¸ù±¾£¬ÈçºÎ½áºÏÕûºÏ¸÷¸ö²»Í¬ÏµÍ³µÄ³ÌÐò¡¢Êý¾Ý±í¡¢¼Ü¹¹£¬ÌṩͳһµÄÍøÕ¾»áԱϵͳ£¬Ò»Ö±ÊÇÀ§ÈźܶàÕ¾³¤µÄÎÊÌ⣬¶øʹÓÃUCenter¿ÉÒÔ½ÏΪ¼òµ¥µÄʵÏÖ²»Í¬ÏµÍ³Ö®¼äµÄÕûºÏÎÊÌâ¡£
¡¡¡¡UCenterÊÇ¿µÊ¢´´ÏëÍƳöµÄÃâ·Ñ¿ªÔ´µÄ½¨Õ¾¹¤¾ß£¬ÊǸ÷¸ö½¨Õ¾²úÆ·Ö®¼äÐÅÏ¢Ö±½Ó´«µÝµÄÒ»¸ö¹¤¾ß£¬¿µÊ¢µÄTeamÔÚÆäDiscuzÂÛ̳ÉÏÊÕ ......
¹úÍâµÄ¿ªÔ´¼¼ÊõÒ²Ó°ÏìºÍÍƶ¯Á˹úÄÚ¿ªÔ´³ÌÐòµÄ·¢Õ¹£¬ÉÏÎÄÎÒ½éÉܵġ¶¹úÍâÓÅÐ㿪ԴPHP½¨Õ¾³ÌÐòÒ»ÀÀ¡·ÖУ¬ºÜ¶à¹úÍ⿪Դ³ÌÐò²¢²»Ì«·ûºÏÖйúÈ˵ÄʹÓÃÏ°¹ß£¬¶ø¹úÄÚÓÐһЩ³§¼Ò»ò¸öÈËÒ²×öÁËһЩ²»´íµÄ²úÆ·£¬²»ÉÙ³ÌÐòÊÇÌṩԴ´úÂëÏÂÔصģ¬ËäÈ»ÓÐЩÔÚÐí¿ÉÐÒéÉϺͿªÔ´Ðí¿ÉÖ¤ÓÐЩ³öÈ룬µ«ÆäÔÚʹÓÃÉÏ»¹ÊÇͦ·ûºÏÖйúÈ˵ÄʹÓÃÏ°¹ß£¬½ñÌìÎÒ¾ ......