Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยด้วยครับ อัพรูปลงฐานข้อมูล ไม่ได้ แต่ทำที่ AppServ v 2.5 ทำได้ เพราะ เซิฟปิด Registry Global =Off บนเซิฟจริง



 

ช่วยด้วยครับ อัพรูปลงฐานข้อมูล ไม่ได้ แต่ทำที่ AppServ v 2.5 ทำได้ เพราะ เซิฟปิด Registry Global =Off บนเซิฟจริง

 



Topic : 090611



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์




ช่วยด้วยครับ อัพรูปลงฐานข้อมูล ไม่ได้ แต่ทำที่ AppServ v 2.5 ทำได้
เพราะที่ เซิฟปิด Registry Global =Off บนเซิฟจริงไว้ เลยแก้ไขรูปไม่ได้

โค้ดเป็นหน้าตาแบบนี้ครับ


Code (PHP)
<?

ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
require_once('../connect/connect.php');
require_once('../connect/function.php');

//=========== กรณีมีการแก้ไขรายการสินค้า
                       if($_GET["Action"]=="Save")
	                   {
						   //===========  บันทึกข้อมูลสินค้า
	                 $sql_up = "update product set ProductCode='$_POST[txtProductCode]',ProductName='$_POST[txtProductName]',Description='$_POST[txtDescription]',Price='$_POST[txtPrice]',PriceNormal='$_POST[txtPriceNormal]',PriceSend='$_POST[txtPriceSend]',Stock='$_POST[txtStock]',Promotion='$_POST[rdoPromotion]',New='$_POST[rdoNew]' where ProductID='$_GET[ProductID]'";
                      $dbquery_up = mysql_query($sql_up);
					  //echo $sql_up;
					//  exit();
					//===========  แก้ไขไฟล์เล็ก

					                  	if(!empty($file))
                                           {
														 @unlink($_POST['oldPicture']); //  รับค่า hidden oldPicture จากฟอร์ม
														$path="../picture";								
														//=========== อัพโหลตไฟล์เล็ก
                                                        @copy( $file ,"$path/$file_name");
														  //=========== ถ้ามีการแก้ไขไฟล์
					    
													  $sql_up = "update product set Picture='$file_name' where ProductID='$_GET[ProductID]'";
		
                                                       $dbquery_up = mysql_query($sql_up);

								 			 }
											 
										 
					  
									echo"<script language='JavaScript'>";
									echo"alert('แก้ไขข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='editproduct.php?ProductID=$_GET[ProductID]';";
									echo"</script>";					  
			 		  }
					  
?>
<html>
<title>..:: ระบบจัดการฐานข้อมูล ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link rel="stylesheet" href="../css/styles.css" type="text/css">
<script language="JavaScript" src="editor.js"></script>
<div align="center"><br>
<?
//===========  อ่านว่าคือสินค้าชนิดใด
$result=select("product","where 1=1 and ProductID='".$_GET["ProductID"]."'");
if(!$result)
{
header("location:product.php");
}

?>
  <table cellspacing=1 cellpadding=4 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
          <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
            <tbody>
              <tr bgcolor=#e5e5e5> 
                <td width="35%" bgcolor="#FFFFFF"> <div align="left"><b><img src="../image/allrowto.gif" width="11" height="11" align="absbottom"> 
                    แก้ไขรายการสินค้า</b></div></td>
                <td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left"> 
                  </div></td>
                <td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="product.php?CatID=<?=$result["CatID"];?>">กลับไป</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</div>

<form name="frm<?=$i;?>" method="post" action="<?=$_SERVER['PHP_SELF'];?>?ProductID=<?=$_GET["ProductID"];?> &Action=Save" enctype="multipart/form-data" onSubmit="return checkvalue()">
<input type="hidden" name="oldPicture" id="oldPicture" value="../picture/<?=$result["Picture"]; ?>"> <!-- ส่งค่ารูปเดิมไปด้วย เพื่อทำ Unlink file -->
  <table cellspacing=1 cellpadding=3 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="31" bgcolor="#FFFFFF"> <script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script> 
<script language="JavaScript">
function checkvalue()
{

		if(parseInt(document.all.txtPrice.value) >= parseInt(document.all.txtPriceNormal.value))
		{
		alert('ราคาพิเศษจะต้องน้อยกว่ากว่าราคาปกติ');
		document.all.txtPrice.focus();
		return false;
		}else
		{ return true; }

}
</script>
          <table width="100%" border="0" cellspacing="2" cellpadding="2">
            <tr> 
              <td width="18%">&nbsp;</td>
              <td width="82%">&nbsp;</td>
            </tr>
            <tr> 
              <td valign="top">รหัสสินค้า <font color="#FF0000">** </font></td>
              <td><input name="txtProductCode" type="text" class="txtbox" id="txtProductCode" value="<?=$result["ProductCode"];?>" maxlength="20" readonly> 
              </td>
            </tr>
            <tr> 
              <td valign="top">สินค้าโปรโมชั่น <font color="#FF0000">** </font></td>
              <td><input name="rdoPromotion" type="radio" value="Yes" <? if($result["Promotion"]=="Yes"){?>checked<?}?>>
                ใช่ 
                <input type="radio" name="rdoPromotion" value="No" <? if($result["Promotion"]=="No"){?>checked<?}?>>
                ไม่ใช่</td>
            </tr>
            <tr> 
              <td valign="top">สินค้าใหม่ <font color="#FF0000">** </font></td>
              <td><input name="rdoNew" type="radio" value="Yes" <? if($result["New"]=="Yes"){?>checked<?}?>>
                ใช่ 
                <input type="radio" name="rdoNew" value="No" <? if($result["New"]=="No"){?>checked<?}?>>
                ไม่ใช่</td>
            </tr>
            <tr> 
              <td valign="top">ชื่อสินค้า <font color="#FF0000">** </font></td>
              <td><input name="txtProductName" type="text" class="txtbox" id="txtProductName" style="width:550" value="<?=$result["ProductName"];?>" maxlength="100"></td>
            </tr>
            <tr> 
              <td valign="top">ราคาปกติ <font color="#FF0000">** </font></td>
              <td><input name="txtPriceNormal" type="text" class="txtbox" id="txtPriceNormal" value="<?=$result["PriceNormal"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr> 
              <td valign="top">ราคาพิเศษ <font color="#FF0000">** </font></td>
              <td><input name="txtPrice" type="text" class="txtbox" id="txtPrice" value="<?=$result["Price"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr>
              <td valign="top">ค่าบริการ</td>
              <td><input name="txtPriceSend" type="text" class="txtbox" id="txtPriceSend" value="<?=$result["PriceSend"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr> 
              <td valign="top">สำนวนสต็อก <font color="#FF0000">** </font></td>
              <td><input name="txtStock" type="text" class="txtbox" id="txtStock" value="<?=$result["Stock"];?>" size="10" maxlength="20"></td>
            </tr>
            <tr> 
              <td valign="top">รูปภาพ <font color="#FF0000">** </font></td>
              <td><img src="../picture/<?=$result["Picture"];?>" width="250" height="300"  /></td>
            </tr>
            <tr> 
              <td valign="top">&nbsp;</td>
              <td><input name="file" type="file" class="txtbox" id="file"></td>
            </tr>
            <tr> 
              <td valign="top">รายละเอียด <font color="#FF0000">** </font></td>
              <td><textarea name="txtDescription" cols="40" rows="10" class="txtbox" id="txtDescription" style="width:550; height:450"><?=$result["Description"];?></textarea> 
                <script language="javascript1.2">
editor_generate('txtDescription');
</script> &nbsp;</td>
            </tr>
            <tr> 
              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td><input name="Submit" type="submit" class="button" value="บันทึก"> 
                <input name="Cancel" type="button" class="button" id="Cancel" value="ยกเลิก" onClick="window.location='product.php?CatID=<?=$result["CatID"];?>';"></td>
            </tr>
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
      </tr>
  
    </tbody>
  </table>
  <table cellspacing=0 cellpadding=4 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
          <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
            <tbody>
              <tr bgcolor=#e5e5e5> 
                <td width="35%" bgcolor="#FFFFFF"> <div align="left"></div></td>
                <td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left"> 
                  </div></td>
                <td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="product.php?CatID=<?=$result["CatID"];?>">กลับไป</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</form>






Tag : PHP, MySQL, Ms SQL Server 2005







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-09 20:13:55 By : mart7612 View : 872 Reply : 4
 

 

No. 1



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์


เขียนโค้ดตรงไหนผิดครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-09 23:32:49 By : mart7612
 


 

No. 2



โพสกระทู้ ( 3,844 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Twitter Facebook

ไฟล์ php อื่นรันได้ ไฟล์ php นี้รันไม่ได้ ไม่น่าเกี่ยวกับ Registry Global =Off น่ะครับ
ดูโค้ดคุณดีๆครับ if(!empty($file)) // $file มาจากไหน ไหนจะ $filename1 อีก เหมือนกระทู้ก่อนหน้าเลยครับ
ซึ่งก็มีหลายท่านช่วยตอบจนแก้ปัญหาได้แล้ว ผมว่าก็น่าจะพอมองออกแล้วหล่ะ ว่ามันน่าจะผิดตรงไหน

อีกเรื่องน่ะครับ การต่อ string ระวังมากๆๆๆเลยน่ะ

Ex1 Code (PHP)
$sql = "insert into table(.....)values('$_POST[inputname]')"; // ทำแบบนี้ โอกาสที่จะ insert ไม่ผ่านสูงมาก


type ข้อมูลที่เป็น varchar, char ในภาษา php ต้องครอบด้วย '...' เสมอ
การรับค่า $_POST หรือ $_GET หรือ ค่าที่ได้จาก mysql_fetch_array,row ต่องใส่ '....' ให้ชื่อมันเสมอ
เช่น $_POST['your_input'] หรือ $_GET['your_value'] หรือ $fetch_object['your_field_name']

Ex2 Code (PHP)
$sql = "insert into table(.....)values('".$_POST['inputname']."')"; //ผลลัพธ์ insert into table(.....)values('your_value');

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-10 00:40:25 By : mangkunzo
 

 

No. 3



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์


ใหม่แบบนี้ ก็ยังไม่ได้ครับ


Code (PHP)
//=========== กรณีมีการแก้ไขรายการสินค้า
				
                       if($_GET["Action"]==Save)
	                   {
	  //===========  บันทึกข้อมูลสินค้า
	 //=========== ถ้ามีการแก้ไขไฟล์
					      if(!empty($_FILES['file1']['name']))
					       //	if(!empty($file))
                                           {
			@unlink($_POST['oldPicture']); //  รับค่า hidden oldPicture จากฟอร์ม
			 $path="../picture";							
			//=========== อัพโหลตไฟล์เล็ก
                     copy($_FILES['file1']['tmp_name'] , $path."/".$_FILES['file1']['name']); //  code ก๊อบไฟล์
		 //=========== บันทึกข้อมูลลงฐานข้อมูล
$sql_up = "update product set ProductCode='".$_POST['txtProductCode']."',ProductName='".$_POST['txtProductName']."',Description='".$_POST['txtDescription']."',Price='".$_POST['txtPrice']."',PriceNormal='".$_POST['txtPriceNormal']."',PriceSend='".$_POST['txtPriceSend']."',Stock='".$_POST['txtStock']."',Promotion='".$_POST['rdoPromotion']."',New='".$_POST['rdoNew']."','";		   
$sql_up = "update category set ProductCode='".$_POST['txtProductCode']."',CheckStock='".$_POST['txtCheck']."',";
$sql_up .= "Picture='".$_FILES['file1']['name']."' where ProductID='".$_POST['ProductID']."'";
	 // $sql_up = "update product set Picture='$file_name' where ProductID='$_GET[ProductID]'";  //ตัวเก่า
               }else{
	 //=========== บันทึกข้อมูล	
	$sql_up = "update product set ProductCode='".$_POST['txtProductCode']."',ProductName='".$_POST['txtProductName']."',Description='".$_POST['txtDescription']."',Price='".$_POST['txtPrice']."',PriceNormal='".$_POST['txtPriceNormal']."',PriceSend='".$_POST['txtPriceSend']."',Stock='".$_POST['txtStock']."',Promotion='".$_POST['rdoPromotion']."',New='".$_POST['rdoNew']."'
where ProductID='".$_POST['ProductID']."'";
							 }
		// echo $sqlquery;
$sqlquery=mysql_query($sql_up);
echo $sqlquery;
 if($sqlquery){ //ข้อความแจ้งว่าเกิดอะไรขึ้น
				echo"<script language='JavaScript'>";
				echo"alert('แก้ไขข้อมูลเรียบร้อยแล้ว');";
				echo"window.location='editproduct.php?ProductID=$_GET[ProductID]';";
				echo"</script>";					  
			 	 }else{
                              echo '<script>alert("แก้ไขข้อมูลไม่สำเร็จ");location.href="editproduct.php?ProductID=$_GET[ProductID]"</script>';
                        }				  
			   }

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-10 00:49:21 By : mart7612
 


 

No. 4



โพสกระทู้ ( 3,844 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Twitter Facebook

แก้จาก if($_GET["Action"]==Save) เป็น if($_GET["Action"]=='Save') ดูก่อนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-10 10:03:05 By : mangkunzo
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยครับ อัพรูปลงฐานข้อมูล ไม่ได้ แต่ทำที่ AppServ v 2.5 ทำได้ เพราะ เซิฟปิด Registry Global =Off บนเซิฟจริง
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่