  | 
              
	              
	                
  
    
	 
        ปัญหา link referring page seems to be wrong จะต้องเปลี่ยนอย่างไร เพื่อให้สามารถ referring ได้ค่ะ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                มีสองปัญหา ปัญหาที่สองดูจะหนักหน่อยค่ะ ใครทราบช่วยด้วยนะค่ะ ขอบพระคุณมากค่ะ 
ปญหาแรก undefined INDEX  ตัว lmName1 
 <?php 
/*** Connect ***/ 
 
	$serverName = "localhost"; 
 
	$userName = "duangjai_root"; 
 
	$userPassword = "jai"; 
 
	$dbName ="duangjai_newversion_bible"; 
 
	$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName); 
 
	mysqli_set_charset($objCon, "utf8"); 
 
?>  
 
<form action="newsearch_show_file_new2.php" method="post" name="form1"> 
 
		โปรดเลือกหัวข้อพระวาจาที่ท่านต้องการศึกษา<br> 
 
		  <select name="lmName1"> 
 
			<option value=""><--เลือกหัวข้อที่จะนำไปสู่ข้อความจากพระวาจา --></option> 
 
		<?php 
 
			$strSQL = "select * from uploadfile ORDER BY id ASC"; 
 
 
	        $objQuery = mysqli_query($objCon,$strSQL); 
 
			 
	 while($result = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{ 
 
		?> 
 
			<option value="<?php echo $result["id"];?>"><?php echo $result["id"]." - ".$result["topic"];?></option> 
 
		<?php 
 
			} 
 
		 ?> 
 
		  </select> 
 
		<input name="btnSubmit" type="submit" value="Submit"> 
 
	</form> 
        
<?php 
 
    $strSQL = "select * from uploadfile where id = '".$_POST["lmName1"]."' "; 
 
	$objQuery = mysqli_query($objCon,$strSQL); 
 
 
ปัญหาที่สอง 
while($result3 = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{	 
              echo $result3["id"]; 
              echo $result3["topic"]; 
              echo $result3["filename"]; 
              echo "<a href=\"newsearch_show_file_new2.php?id=$id\" target=\"_blank\">{$result3["filename"]}</a>"; 
			} 
 
หรือ เกิดจาก การเรียก file .php นี้ตาม Code ด้านล่างนี้แล้ว 
<html> 
<head> 
<meta http-equiv=Content-Type content="text/html; charset=utf-8">newsearch_show_new2_file</title> 
<link rel="stylesheet" href="../css/style.css"  /> 
</head> 
 
<body> 
<?php 
$serverName = "localhost"; 
 
	$userName = "duangjai_root"; 
 
	$userPassword = "jai"; 
 
	$dbName ="duangjai_newversion_bible"; 
 
	$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName); 
 
	mysqli_set_charset($objCon, "utf8"); 
 
echo $_POST["lmName1"]; 
 
		echo "<hr>"; 
 
        $id = $_GET['id']; 
        $strSQL = "SELECT * FROM uploadfile WHERE id = '".$_GET['id']."' "; 
        $objQuery = mysqli_query($objCon,$strSQL); 
 
  
$pat_img = "^(image)"; 
$pat_swf = "(flash)$"; 
 
//ถ้าไม่ใช่ชนิดรูปภาพ ให้เข้าสู่การดาวน์โหลด 
if(!eregi($pat_img, $type) && !eregi($pat_swf, $type)) { 
 
 while($result = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{	 
 $name = mysql_result($result,0,"file_name"); 
 $size = mysql_result($result,0,"file_size"); 
 $type = mysql_result($result,0,"file_type"); 
 $content = mysql_result($result,0,"file_content"); 
 header("Content-Type: $type"); 
 header("Content-Length : $size"); 
 header("Content-Disposition : attachment; filename=$name"); 
	 
 	echo $content; 
	exit(); 
} 
} 
 
//ถ้าเป็นรูปภาพให้แสดงผลในแบบเว็บเพจ 
echo "<html><body>"; 
 
if(eregi($pat_img, $type)) { 
	echo "<img src=\"read_image.php?id=$id\" />"; 
} 
else if(eregi($pat_swf, $type)) { 
	echo  "<object width=468 height=60> 
	 			<param name=movie value=\"read_image.php?id=$id\" /> 
	 			<embed width=468 height=60 src=\"read_image.php?id=$id\"></embed> 
 			 </object>"; 
} 
 
echo "</body></html>"; 
?> 
</body> 
</html> 
<?php 
 
	mysqli_close($objCon); 
 
?> 
  
 
 
 
 
  Tag : PHP, MySQL, Appserv, XAMPP               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2018-11-04 11:59:20 2018-11-04 12:00:26	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-11-04 11:58:40 | 
                      By :
                          494384544414604 | 
                      View :
                          1708 | 
                      Reply :
                          2 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เอา tag ภาษาครอบให้หน่อยครับ จะได้อ่านง่าย 
 
                         
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-11-04 20:44:47 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   ตอบความคิดเห็นที่ : 1 เขียนโดย : Chaidhanan เมื่อวันที่ 2018-11-04 20:44:47 
รายละเอียดของการตอบ ::
  ... เรียน คุณ Chaidhanan พยายาม แก้ไข ตาม Code ด้านล่างนี้ แล้วก็ยังมีปัญหาค่ะ ช่วยแนะนำหน่อยค่ะ ...ขอบพระคุณนะค่ะ อยากให้สามารถทำงานได้ จะได้เป็นประโยชน์ให้คนอื่นๆ ค่ะ
  
file PHP  file แรก ที่ทำให้เกิด การ error เรื่อง undefined 
 
<html> 
<head> 
<meta http-equiv=Content-Type content="text/html; charset=utf-8">newsearch_new2</title> 
<link rel="stylesheet" href="../css/style.css"  /> 
</head> 
<body> 
<h3> 
  <?php 
/*** Connect ***/ 
 
	$serverName = "localhost"; 
 
	$userName = "duangjai_root"; 
 
	$userPassword = "jai"; 
 
	$dbName ="duangjai_newversion_bible"; 
 
	$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName); 
 
	mysqli_set_charset($objCon, "utf8"); 
 
 
?>  
 
<form action="newsearch_show_file_new2.php" method="post" name="form1"> 
 
		โปรดเลือกหัวข้อพระวาจาที่ท่านต้องการศึกษา<br> 
 
		  <select name="lmName1"> 
 
			<option value=""><--เลือกหัวข้อที่จะนำไปสู่ข้อความจากพระวาจา --></option> 
 
		<?php 
 
			$strSQL = "select * from uploadfile ORDER BY id ASC"; 
 
		//	$objQuery = mysql_query($strSQL); 
 
 
 
	        $objQuery = mysqli_query($objCon,$strSQL); 
 
			/// 
 
	 while($result = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{ 
 
		?> 
 
			<option value="<?php echo $result["id"];?>"><?php echo $result["id"]." - ".$result["topic"];?></option> 
 
		<?php 
 
			} 
 
		 ?> 
 
		  </select> 
 
		<input name="btnSubmit" type="submit" value="Submit"> 
 
	</form> 
 
<?php 
//แสดงรายชื่อไฟล์ที่อยู่ในฐานข้อมูล 
 
 
	$result2 = mysql_query("select * from uploadfile where id=$_POST["lmName1"]); 
 
 
 
//ถ้ามีไฟล์ในฐานข้อมูล ให้แสดงเป็นรายการแบบตาราง 
echo "<table border=1 cellpadding=5 cellspacing=1> 
		<caption>รายชื่อไฟล์ที่เก็บไว้ในฐานข้อมูล</caption>"; 
	 
	  $objQuery = mysqli_query($objCon,$result2); 
 
	 while($result3 = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{	 
              echo $result3["id"]; 
              echo $result3["topic"]; 
              echo $result3["filename"]; 
              echo "<a href=\"newsearch_show_file_new1.php?id=$id\" target=\"_blank\">{$result3["filename"]}</a>"; 
			} 
 
?> 
</body> 
</html> 
<?php 
 
	mysqli_close($objCon); 
 
?> 
file ที่ถูกเรียก และทำให้เกิดการ error referring 
<html> 
<head> 
<meta http-equiv=Content-Type content="text/html; charset=utf-8">newsearch_show_new2_file</title> 
<link rel="stylesheet" href="../css/style.css"  /> 
</head> 
 
<body> 
<?php 
$serverName = "localhost"; 
 
	$userName = "duangjai_root"; 
 
	$userPassword = "jai"; 
 
	$dbName ="duangjai_newversion_bible"; 
 
	$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName); 
 
	mysqli_set_charset($objCon, "utf8"); 
 
 
 
 
echo $_POST["lmName1"]; 
 
		echo "<hr>"; 
 
        $id = $_GET['id']; 
        $strSQL = "SELECT * FROM uploadfile WHERE id = '".$_GET['id']."' "; 
        $objQuery = mysqli_query($objCon,$strSQL); 
 
  
$pat_img = "^(image)"; 
$pat_swf = "(flash)$"; 
 
//ถ้าไม่ใช่ชนิดรูปภาพ ให้เข้าสู่การดาวน์โหลด 
if(!eregi($pat_img, $type) && !eregi($pat_swf, $type)) { 
 
 while($result = mysqli_fetch_array($objQuery,MYSQLI_ASSOC)) 
 
			{	 
 $name = mysql_result($result,0,"file_name"); 
 $size = mysql_result($result,0,"file_size"); 
 $type = mysql_result($result,0,"file_type"); 
 $content = mysql_result($result,0,"file_content"); 
 header("Content-Type: $type"); 
 header("Content-Length : $size"); 
 header("Content-Disposition : attachment; filename=$name"); 
	 
 	echo $content; 
	exit(); 
} 
} 
 
//ถ้าเป็นรูปภาพให้แสดงผลในแบบเว็บเพจ 
echo "<html><body>"; 
 
if(eregi($pat_img, $type)) { 
	echo "<img src=\"read_image.php?id=$id\" />"; 
} 
else if(eregi($pat_swf, $type)) { 
	echo  "<object width=468 height=60> 
	 			<param name=movie value=\"read_image.php?id=$id\" /> 
	 			<embed width=468 height=60 src=\"read_image.php?id=$id\"></embed> 
 			 </object>"; 
} 
 
echo "</body></html>"; 
?> 
</body> 
</html> 
<?php 
 
	mysqli_close($objCon); 
 
?>                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2018-11-05 18:36:57              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-11-05 16:11:43 | 
                        By :
                            494384544414604 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |