  | 
              
	              
	                
  
    
	 
        ปัญหาภาษาไทยอีกแล้ว พยายามสร้างฐานข้อมูลตามตัวอย่างและแก้ไขข้อมูลให้เป็นภาษาไทย แต่เมื่อดึงออกมาแสดงหน้าเว็บไม่ได้     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                พยายามทดลองตาม Code และดูการกำหนดค่ารหัสภาษา ให้เป็น สมัยปัจจุบัน แต่เมื่อเข้าไปลองแก้ไขเปลี่ยนแปลงเป็นภาษาไทย ใน Database แล้วเรียกออกมาดูกลับอ่านไม่ได้ ไม่ทราบว่าต้องทำอย่างไร ผู้รู้ช่วยแนะนะหน่อยค่ะ 
 
<!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>Untitled Document</title> 
</head> 
 
<body> 
<?php 
	ini_set('display_errors', 1); 
	error_reporting(~0); 
 
	$serverName = "localhost"; 
	$userName = "root"; 
	$userPassword = ""; 
	$dbName = "mydatabase"; 
    $mysqli = new mysqli($serverName,$userName,$userPassword,$dbName); 
	 $mysqli->set_charset("utf8_general_ci"); 
	 
	$conn = new mysqli($serverName,$userName,$userPassword,$dbName); 
 
	$strCustomerID = "C001"; 
	$sql = "SELECT * FROM customer WHERE CustomerID = ? "; 
	$stmt = $conn->prepare($sql); 
	$stmt->bind_param('s', $strCustomerID); //   s - string, b - blob, i - int, etc 
 
	/*** for 2 Parameters 
		$strCustomerID = "C001"; 
		$strEmail = "[email protected]"; 
		$sql = "SELECT * FROM customer WHERE CustomerID = ? AND Email = ? "; 
		$stmt = $conn->prepare($sql); 
		$stmt->bind_param('ss', $strCustomerID,$strEmail); //   s - string, b - blob, i - int, etc 
	**/ 
 
	$stmt ->execute(); 
 
	$result = $stmt->get_result(); 
	$row = $result->fetch_assoc(); 
 
	if($row) 
	{ 
		echo $row["CustomerID"]."<br>"; 
		echo $row["Name"]."<br>"; 
		echo $row["Email"]."<br>"; 
		echo $row["CountryCode"]."<br>"; 
		echo $row["Budget"]."<br>"; 
		echo $row["Used"]."<br>"; 
	} 
 
	$conn->close(); 
?> 
</body> 
</html> 
 
 
 
 
  
 
  
 
  
 
 
 
 
  Tag : PHP, MySQL, HTML, XAMPP               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2018-10-30 16:11:44	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-10-30 16:07:51 | 
                      By :
                          494384544414604 | 
                      View :
                          2118 | 
                      Reply :
                          5 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ลองแบบนี้ code เก่า ปัจจุบันแนะนำเป็น mysqli 
ไฟล์ connect database 
Code (PHP) 
$objConnect = mysql_connect("$serverName","$userName","$userPassword") or die("Error Connect to Database");
	$objDB = mysql_select_db("$dbName");
	mysql_query("SET character_set_results=utf8");
	mysql_query("SET character_set_client=utf8");
	mysql_query("SET character_set_connection=utf8");
 
 
หน้าที่แสดงข้อมูลอย่างลืมเปิด 
Code (PHP) 
<meta charset="UTF-8">
                         
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2018-10-30 16:14:28 2018-10-30 16:16:07              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-30 16:13:50 | 
                        By :
                            nobetaking | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 คุณแมวหลังเขาค่ะ ตัวอย่าง Code ที่คุณให้ตัวอย่างมา จะเป็นลักษณะของ Code แบบเก่าใช่ไหมค่ะ  เวลาไปใช้ ระบบมันจะพยายามบอกว่าให้ mysql_connect(): The mysql extension is deprecated and will be removed in the future:use mysqli or PDO instead 
 
 
หากดิฉันใช้ Code ดังตัวอย่างที่พยายามจะใช้ในรูปแบบ ของ mysqli จะสามารถ แก้ปัญหาภาษาไทย ได้อย่างไร ใครทราบช่วยแนะนำหน่อยค่ะ 
 
กำลังจะลองศึกษาเพิ่มเติมจาก link 
 
https://www.thaicreate.com/php/php-mysql-mysqli.html                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2018-10-30 22:55:31              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-30 21:41:02 | 
                        By :
                            494384544414604 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบพระคุณทุกท่านค่ะ เรียนรู้จาก ข้อมูลที่ทุกท่านตอบและฝึกฝนทำ ค่ะ แก้ปัญหานี้ได้แล้ว 
 
ใช้  mysqli_set_charset($objCon, "utf8")                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-31 12:13:56 | 
                        By :
                            494384544414604 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ฝึกเขียนแบบ oop ไว้ครับ จะช่วยให้เขียนได้สั้นกว่า แบบความเห็น Mr.V (คห 3) 
 
Code (PHP) 
mysqli_set_charset($objCon, "utf8")
//แก้เป็น
$objCon->set_charset("utf8")
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-31 12:29:56 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |