  | 
              
	              
	                
  
    
	 
        เก็บข้อมูลลงฐานข้อมูลทำไมเป็นภาษาต่างดาวครับช่วยที     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ผมว่า ลองค้นดูในบอร์ดก่อนดีกว่าครับ มีวิธีแก้ัปัญหา พร้อมโค้ดด้วยครับผม 
 
ตอบมาเยอะแล้วกับคำถามนี้ครับ .. สู้ ๆ นะครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 15:50:29 | 
                        By :
                            deawx | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ลองดู 
<!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>RaybanShop</title>
</head>
โค๊ดconnect.php
<html>
<body>
<?
$host = "localhost";
$username = "root";
$password = "makoto";
$objConnect = mysql_connect($host,$username,$password);
mysql_query("SET NAMES UTF8");
if($objConnect)
{
echo "MySQL Connected";
}
else
{
echo "MySQL Connect Failed : Error : ".mysql_error();
}
mysql_close($objConnect);
?>
</body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 16:14:44 | 
                        By :
                            weaned | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ในการเช็ตภาษา คุณต้องทำเหมือนกันทั้งระบบ 
DB ต้องเซ็ต collection เป็น utf8_general_ci (ที่แนะนำ หรือตัวอื่นก็ได้) 
เบราเซอร์ต้องกำหนด <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> (ที่แนะนำ หรือตัวอื่นก็ได้) 
ก่อนบรรทัด INSERT ก็ใส่ mysql_query("SET NAMES UTF8"); 
 
หลักๆก็ประมาณนี้ 
 
หรือไม่ก็ดูจากกระทู้ที่ No.7 เอามาให้ก็ได้                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2014-01-14 16:35:21              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 16:33:32 | 
                        By :
                            arm8957 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เปลี่ยนหน้าเป็น  
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
 
 
แล้วทำตามข้างบน UTF8                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 16:59:26 | 
                        By :
                            teez1232002 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 แต่มีปัญหาใหม่คือ หน้าแสดง ภาษาไทยกลายเป็น???? แทนแล้วครับทีนี้ทำไงดี                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 17:12:47 | 
                        By :
                            gotoloop | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 คุณก็ใส่ตัวนี้ไปสิ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> ไม่น่าจะมีปัญหานะ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 17:15:56 | 
                        By :
                            arm8957 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RaybanShop</title>
</head>
<?
$conn = mysql_connect("localhost","root","makoto");
mysql_select_db("rayban", $conn);
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM orders WHERE OrderID = '".$_GET["OrderID"]."' ";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$objResult = mysql_fetch_array($objQuery);
?>
<br><br><br>
<style type="text/css">
body
{
background: url(img/bgindex.jpg) 
no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
<body>
<marquee> <font size="+4" face="Magneto" color="#FF0000">Welcome to RaybanShop!!</font> </marquee> 
<center>
<font size="+3" face="MisterEarl BT"color="#FFFFFF"><u>Your profile</u></font>
<table width="304" border="1">
<tr>
<td bgcolor="#CCCCCC" width="71"><b>OrderID</b></td>
<td bgcolor="#FFFFFF" width="217"> <?=$objResult["OrderID"];?></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" width="71"><b>Name</b></td>
<td bgcolor="#FFFFFF" ><?=$objResult["Name"];?></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Address</b></td>
<td bgcolor="#FFFFFF"><?=$objResult["Address"];?></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Tel</b></td>
<td bgcolor="#FFFFFF"><?=$objResult["Tel"];?></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Phone</b></td>
<td bgcolor="#FFFFFF"><?=$objResult["Phone"];?></td>
</tr>
</table>
<br>
<font size="+3" face="MisterEarl BT"color="#FFFFFF"><b><u>Your order</u></b></font>
<table width="400" border="1">
<tr>
<td bgcolor="#CCCCCC"width="101"><center><b>ProductID</b></center></td>
<td bgcolor="#CCCCCC"width="82"><center><b>ProductName</b></center></td>
<td bgcolor="#CCCCCC"width="82"><center><b>Price</b></center></td>
<td bgcolor="#CCCCCC"width="79"><center><b>Qty</b></center></td>
<td bgcolor="#CCCCCC"width="79"><center><b>Total</b></center></td>
</tr>
<?
$Total = 0;
$SumTotal = 0;
$strSQL2 = "SELECT * FROM orders_detail WHERE OrderID = '".$_GET["OrderID"]."' ";
$objQuery2 = mysql_query($strSQL2) or die(mysql_error());
while($objResult2 = mysql_fetch_array($objQuery2))
{
$strSQL3 = "SELECT * FROM product WHERE ProductID = '".$objResult2["ProductID"]."' ";
$objQuery3 = mysql_query($strSQL3) or die(mysql_error());
$objResult3 = mysql_fetch_array($objQuery3);
$Total = $objResult2["Qty"] * $objResult3["Price"];
$SumTotal = $SumTotal + $Total;
?>
<tr>
<td bgcolor="#FFFFFF"><center><?=$objResult2["ProductID"];?></center></td>
<td bgcolor="#FFFFFF"><center><?=$objResult3["ProductName"];?></center></td>
<td bgcolor="#FFFFFF"><center><?=$objResult3["Price"];?></center></td>
<td bgcolor="#FFFFFF"><center><?=$objResult2["Qty"];?></center></td>
<td bgcolor="#FFFFFF"><center><?=number_format($Total,2);?></center></td>
</tr>
<?
}
?>
</table>
<font size="+2" face="MisterEarl BT" color="#FF0000">The total cost for you is = <?=number_format($SumTotal,2);?> bath. <br><br>
Thank you!!</font><br><br>
<font size="+2" face="MisterEarl BT" color="#6600FF"><a href="home1.php">Go to RaybanShop</a></font>
<?
mysql_close($conn);
?>
</center>
</body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 17:33:08 | 
                        By :
                            arm8957 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 แก้ปัญหาภาษาไทย php กับ MySQL (TIS-620 กับ UTF-8) 
 
 
                         
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2014-01-14 18:31:27 | 
                        By :
                            mr.win | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |