|  | 
	                
  
    | 
	 
        คือติดปัญหาอยู่ตรงหน้า update.phpหน่ะครับ"วานผู้รู้ชี้แจงหน่อยครับ"     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | เริ่มจากหน้าinsert.phpสามารถแอดข้อมูลเข้าได้ทุกฟิล 
 Code (PHP)
 
 <?
	session_start();
	if (($user=="root") && ($password=="123"))
	{
	if(!$send) {
?>
	<form method="post" action="<? $PHP_SELF; ?>" enctype = "multipart/form-data">
				<h3><b>เพิ่มรายการห้องพัก</b></h3><br>
				ประเภทห้อง: <input type="text" name="type"><br>
				ขนาด:  <input type="text" name="size"><br>
				ราคา/วัน:  <input type="text" name="price_day"><br>
				ราคา/เดือน:  <input type="text" name="price_month"><br>
				<input type = "hidden" name = "MAX_FILE_SIZE" value = "1000000">
				รูปภาพ(ขนาดไม่เกิน 1MB):  <input type="file" name="picture"><br>
				<input type="submit" value="ตกลง" name="send">
				<input type="reset" value="ยกเลิก" name="cancel">
			</form>
<?
	}
	else	
	{
	$path_pic="C:/AppServ/www/Study/apartment/image";
			// * * *  if ($picture != none)
			if($_FILES["picture"])
			{
				$image = $_FILES["picture"]["name"];
				$tmp = $_FILES["picture"]["tmp_name"];
				// if ($picture=copy($_FILES["picture"]["tmp_name"],"$path_pic/".$_FILES["picture"]["name"]))
				 if (copy($tmp,$path_pic."/".$image))
				{
					// * * * $image = $_FILES["picture"]["name"];
			$link = mysql_connect("localhost", "root", "1234");	// กำหนดชื่อโฮสต์, user name และ รหัสผ่าน
		mysql_query("Use room;");	// เรียกใช้ฐานข้อมูล room
		mysql_query("set NAMES tis620");
		// เรียกใช้คำสั่งเพิ่มเรคคอร์ดใหม่ลงในตาราง room_data
	$sql = "Insert Into room_data(room_type, room_size, priceperday, pricepermonth, picture) Values ('$type', '$size', '$price_day', ' $price_month', '$image');";
	$result = mysql_query($sql);
	if ($result)
	{
		echo "เพิ่มรายการห้องพักใหม่แล้ว<p>";
		mysql_close($link);
	}
	else
	{
		echo "ไม่สามารถเพิ่มรายการห้องใหม่ได้<p>";
	}
			
		}
		else
			print ("Error copying file.");
	}
	else
		echo "No file to be uploaded!";
	}
    }
	else
	{
		echo "Invalid to entry the Admin Page";
	}
?>
 
 
 Tag : - - - -
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2010-07-21 20:20:34 | By :
                          nakim13 | View :
                          1508 | Reply :
                          10 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ส่วนนี้หน้าแสดงข้อมูลน่ะครับก็แสดงข้อมูลเหมือนปกติ <?
 $path = "http://localhost/study/apartment/image/";
 echo "<center><h1><u>รายละเอียดห้องพัก</u></h1></center>";
 echo "<hr>";
 echo "<table border=1>
 <tr>
 <td><center>ประเภทห้อง</center></td>
 <td><center>ขนาด (ตร.ม.)</center></td>
 <td><center>ราคา/วัน (บาท)</center></td>
 <td><center>ราคา/เดือน (บาท)</center></td>
 <td><center>รูปภาพ</center></td>
 </tr>";
 
 $link = mysql_connect("localhost", "root", "1234");		// กำหนดชื่อโฮสต์,  user name และ รหัสผ่าน
 mysql_query("Use room;");		// เรียกใช้ฐานข้อมูล room
 mysql_query("set NAMES tis620");
 $sql = "Select * From room_data;";	// ดึงเรคคอร์ดทั้งหมดจากตาราง room_data
 $result = mysql_query($sql);
 while ($dbarr = mysql_fetch_array($result))
 {
 echo "<tr>
 <td><center>$dbarr[room_type]</center></td>
 <td><center>$dbarr[room_size]</center></td>
 <td><center>$dbarr[priceperday]</center></td>
 <td><center>$dbarr[pricepermonth]</center></td>
 <td><center><img src=".$path.$dbarr[picture]." width=150 height=100></center></td>
 </tr>";
 }
 echo "</table>";
 mysql_close($link);
 ?>
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 20:26:32 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | แล้วก็มาหน้าที่มีปัญหาก็คือหน้านี้น่ะครับ คือว่าอัฟข้อมูลขนาด*ราคา-วัน*ราคา-เดือน*ได้แต่ถ้าอัฟรูป-รูปมันก็จะไม่อัฟหน่ะครับ
 <?
 ob_start();
 echo  "<body  bgcolor=#CC9900  >
 <table  width=700  height=480  border=0>
 <tr>
 <td  height=119  colspan=2  bgcolor=#006600><h1><center>
 <font  color=#FFFFFF>
 ผู้ดูแลระบบ</font></center></h1><br>
 </td>
 </tr>
 <td  width=1007 bgcolor=#FFFFFF>";
 session_start();
 if (($user =="root") && ($password=="123"))
 {
 if (!$send)
 {
 echo "<form method=post action=$PHP_SELF enctype = multipart/form-data>
 <input type=hidden name=code value=$id>
 ประเภทห้อง: <input  type=text  name=type  value=$room_type> <br>
 ขนาดห้อง: <input  type=text  name=size  value=$room_size> <br>
 ราคา/วัน: <input  type=text  name=priceday  value=$price_day> <br>
 ราคา/เดือน: <input  type=text  name=pricemonth  value=$price_month> <br>
 <input type = hidden name = MAX_FILE_SIZE value = 1000000>
 รูปภาพ(ขนาดไม่เกิน 1MB):  <input type=file name=picture><br>
 <input type=submit value=ตกลง name=send>
 <input type=reset value=ยกเลิก  name=cancel>
 </form>";
 }
 else
 {
 $path_pic="C:/AppServ/www/Study/apartment/image";
 // * * *  if ($picture != none)
 if($_FILES["picture"])
 $image = $_FILES["picture"]["name"];
 $tmp = $_FILES["picture"]["tmp_name"];
 if ($picture=copy($_FILES["picture"]["tmp_name"],"$path_pic/".$_FILES["picture"]["name"]))
 if (copy($tmp,$path_pic."/".$image))
 // * * * $image = $_FILES["picture"]["name"];
 $link = mysql_connect("localhost","root","1234");
 //  กำหนดชื่อโฮสต์,  user  name  และ รหัสผ่าน
 mysql_query("Use room;");   //  เรียกใช้ฐานข้อมูล    room
 mysql_query("set NAMES tis620");
 $sql = "Update room_data Set room_type = '$type', room_size = '$size',  priceperday = '$priceday', pricepermonth = '$pricemonth', picture = ' $image' Where room_id = '$code';";
 $result = mysql_query ($sql);
 if ($result)
 {
 echo "แก้ไขรายการห้องพักแล้ว<pr>";
 mysql_close($link);
 }
 else
 {
 echo "ไม่สามารถแก้ไขรายการห้องพักได้<pr>";
 }
 }
 }
 else
 {
 echo  "Invalid to entry the Admin Page";
 }
 include  "load_room.php";
 echo  "</td>
 <td  with=190  bgcolor=#FFFF66><ul>
 <li><a  href=insert_admin.php>เพิ่มข้อมูลรายการห้อง  </a></li>
 <li><a  href=load_room_admin.php>แก้ไข-ลบข้อมูลรายการห้อง  </a></li>
 <li><a  href=logout_admin.php>ออก  </a></li>
 </ul>
 </td></table>";
 ob_end_flush();
 ?>
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 20:33:10 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมทำกับเครื่องpcทุกอย่างเป็นปกติครับไม่มีปัญหาอาราย แต่พอมาลองกับโน๊ตบุ๊คมันกับอัฟไม่ได้ซะงั้น คือผมต้องเอางานไปพรีเซนต์หน่ะครับ
 วานผู้รู้ให้แสงสว่างหน่อยครับ...ปวดหัวมากๆเลย
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 20:36:45 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ถ้า pc ได้แล้วทำไม่ laptop มานไม่ได้อ่า 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 20:44:56 | By :
                            Dragons_first |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมก็งงอยู่ครับ...ลบแอดเซิฟ ลง ใหม่ ไป หลาย รอบ แล้ว อ่ะ ครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 21:16:55 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | คือตอนแรกไฟล์insert.phpมันเป็นแบบนี้น่ะครับ ในpcมันรันผ่านน่ะครับแต่กับโน๊คบุ๊คมันฟ้องว่าWarning: copy(Studio-1.jpg) [function.copy]: failed to open stream: No such file or directory in C:\AppServ\www\apartment\insert_room.php on line 24
 ผมก็เลยต้องแก้ใหม่เป็นไฟล์อันบนสุดหน่ะครับ
 <?
 session_start();
 if (($user=="root") && ($password=="123"))
 {
 if(!$send) {
 ?>
 <form method="post" action="<? $PHP_SELF; ?>">
 <h3><b>เพิ่มรายการห้องพัก</b></h3><br>
 ประเภทห้อง: <input type="text" name="type"><br>
 ขนาด:  <input type="text" name="size"><br>
 ราคา/วัน:  <input type="text" name="price_day"><br>
 ราคา/เดือน:  <input type="text" name="price_month"><br>
 รูปภาพ:  <input type="file" name="picture"><br>
 <input type="submit" value="ตกลง" name="send">
 <input type="reset" value="ยกเลิก" name="cancel">
 </form>
 <?
 }
 else
 {
 $path_pic="http://localhost/apartment/images";
 if ($picture != none)
 {
 if (copy ($picture, "$path_pic/$type.jpg"))
 {
 $image = $type.".jpg";
 $link = mysql_connect("localhost", "root", "1234");	// กำหนดชื่อโฮสต์, user name และ รหัสผ่าน
 mysql_query("Use room;");	// เรียกใช้ฐานข้อมูล room
 mysql_query("set NAMES tis620");
 // เรียกใช้คำสั่งเพิ่มเรคคอร์ดใหม่ลงในตาราง room_data
 $sql = "Insert Into room_data(room_type, room_size, priceperday, pricepermonth, picture) Values ('$type', '$size', '$price_day', ' $price_month', '$image');";
 $result = mysql_query($sql);
 if ($result)
 {
 echo "เพิ่มรายการห้องพักใหม่แล้ว<p>";
 mysql_close($link);
 }
 else
 {
 echo "ไม่สามารถเพิ่มรายการห้องใหม่ได้<p>";
 }
 
 }
 else
 print ("Error copying file.");
 }
 else
 echo "No file to be uploaded!";
 }
 }
 else
 {
 echo "Invalid to entry the Admin Page";
 }
 ?>
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 21:23:39 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ก็เลยต้องแก้ไฟล์update.phpตาม มันเป็นอารายหรอครับแบบนี้...มีทางไหนที่พอเป็นไปได้บ้าง
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 21:25:33 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ปัญหาไม่ได้อยู่กับการย้ายเครื่องหรอก อยู่กับ config ที่ไม่เหมือนกัน ให้เดา PC เปิดใช้ register_global แต่ notebook ไม่
 
 แล้วควรใช้ $_FILES และ enctype="multipart/form-data"
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-21 22:40:22 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบคุณมากครับ  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-07-24 09:06:25 | By :
                            nakim13 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | แก้2บรรทัด ใน update.php ตามนี้ดูครับ 
 
 รูปภาพ(ขนาดไม่เกิน 1MB): <input type=file name=picture value=$image><br>
 
 
 
 $sql = "Update room_data Set room_type = '$type', room_size = '$size', priceperday = '$priceday', pricepermonth = '$pricemonth', picture = '$image' Where room_id = '$code';";
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2015-01-11 14:54:55 | By :
                            ฺBlack |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |