  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                 Code ของ file แรก ที่ทำให้เกิด การเรียก อีก file แล้วมีปัญหา 
Code (PHP) 
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">newsearch_new3</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_new3.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']."' ")or die(mysql_error());
//ถ้ามีไฟล์ในฐานข้อมูล ให้แสดงเป็นรายการแบบตาราง
echo "<table border=1 cellpadding=5 cellspacing=1>
		<caption>รายชื่อไฟล์ที่เก็บไว้ในฐานข้อมูล</caption>";
		
//ส่วนฟิลด์ของตาราง
echo "<tr>";
$num_fields = mysql_num_fields($result2);
$num_fields = $num_fields - 1;
for($i = 0; $i < $num_fields - 1; $i++) {		// -1 เพราะจะไม่แสดงฟิลด์ที่เป็นเนื้อหาของไฟล์
	echo "<th>" . mysql_field_name($result2, $i) . "</th>";
}
echo "</tr>";
//อ่านข้อมูลจากแต่ละแถว
while($data = mysql_fetch_array($result2)) {
		echo  "<tr valign=top>";
		
		$id = $data[0];
		for($i = 0; $i < $num_fields - 1; $i++) {	//อ่านข้อมูลจากแต่ละฟิลด์
			echo "<td>";
			
			//ถ้าเป็นฟิลด์ที่แสดงชื่อไฟล์ ให้สร้างลิงค์เพื่อเชื่อมโยงไปยังเพจแสดงไฟล์
		 	if($i == 2) {   
				echo "<a href=\"newsearch_show_file_new3.php?id=$id\" target=\"_blank\">{$data[$i]}</a>";
			}
			else {						//ถ้าเป็นฟิลด์อื่นๆ ให้แสดงข้อมูลตามปกติ
				echo  $data[$i];
			}
			echo "</td>";
		}
		echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
 
 
file ที่สองที่มีปัญหาให้เกิด error referring 
Code (PHP) 
<?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, HTML, Apache, XAMPP               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2018-11-06 20:53:16	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-11-06 20:48:53 | 
                      By :
                          494384544414604 | 
                      View :
                          786 | 
                      Reply :
                          1 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |