|  | 
	                
  
    | 
	 
        [PHP] เขียนข้อมูลลงไฟล์ txt เป็นภาษาไทยแล้วขึ้น ?????????????????????????????     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | คือผมต้องการดึงข้อมูลจาก DB แล้วเขียนลงไฟล์ ปัญหาคือพอเขียนลงแล้วมันขึ้น ????????????????? นี่โค้ดนะครับ
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>EXPORT FILE TO TXT</title>
 </head>
 <body>
 <?
 $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
 $objDB = mysql_select_db("test_writefile");
 $strSQL = "select * from  district";
 $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
 mysql_query("SET NAMES UTF8");
 
 $strFileName = "data.txt";
 $objFopen = fopen($strFileName, 'w');
 
 while($objResult = mysql_fetch_array($objQuery))
 {
 $strText1 = " ".$objResult['PROVINCE_CODE'];" \n";
 $wstrText1=iconv("UTF-8","TIS-620",$strText1);
 fwrite($objFopen, $wstrText1);
 $strText2 = " ".$objResult['DISTRICT_CODE'];" \n";
 $wstrText2=iconv("UTF-8","TIS-620",$strText2);
 fwrite($objFopen, $wstrText2);
 $strText3 = $objResult['NAME_LOCAL'];
 $wstrText3=iconv("UTF-8","TIS-620",$strText3);
 fwrite($objFopen, $wstrText3);
 }
 if($objFopen)
 {
 echo "File writed.";
 }
 else
 {
 echo "File can not write";
 }
 
 fclose($objFopen);
 ?>
 </body>
 </html>
 
 นอนนี้ก็งมโข่งอยู่ครับ มีวิธีทำให้เขียนข้อมูลเป็นภาษาไทยได้มั้ยครับ ผมใช้ Apserv Version 2.5.10 ครับ
 
 
 
 Tag : PHP, MySQL
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2011-10-04 16:22:12 | By :
                          Chaan | View :
                          3317 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | มันติดตรงนี้แหละ ปรกติผมก็เซ็ทให้เป็น utf-8 มันก้ได้แล้ว ส่วนของคุณ เลือกเอาสักอย่างครับ $wstrText1=iconv("UTF-8","TIS-620",$strText1);
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-10-04 16:32:58 | By :
                            Dragons_first |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองแก้ตามที่บอกแล้วครับมันก็ยังไม่หาย 
 $wstrText1=iconv("UTF-8","",$strText1);
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-10-04 16:41:16 | By :
                            Chaan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองเปลี่ยนจากTIS-620 เป็น  windows-874 ดูคับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-10-04 17:35:27 | By :
                            ico_2u |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |