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,028

HOME > PHP > PHP Forum > อัฟรูป ไม่เข้าฐานข้อมูลครับอันนี้ ในเครื่ง ทำได้นะแต่ Host ไม่ได้



 

อัฟรูป ไม่เข้าฐานข้อมูลครับอันนี้ ในเครื่ง ทำได้นะแต่ Host ไม่ได้

 



Topic : 064968



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



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



อัฟรูป ไม่เข้าฐานข้อมูลครับอันนี้ ในเครื่ง ทำได้นะแต่ Host ไม่ได้
Code (PHP)
<?
ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
require_once('../connect/connect.php');
?>
<html>
<title>..:: ระบบจัดการฐานข้อมูล ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" href="../css/styles.css" type="text/css">
 
<div align="center"><br>
  <table cellspacing=1 cellpadding=4 width="59%" 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="head.php">กลับไปหน้าหลัก</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</div>
<?				//=========== กรณีมีการแก้ไขหมวดสินค้า
                       if($_POST["update"]==True)
	                   {
						   //=========== บันทึกข้อมูล
	                  $sql_up = "update category set CategoryName='$_POST[txtCategoryName]',CheckStock='$_POST[txtCheck]' where CatID='$_POST[CatID]'";
                    
					//echo $sql_up ;
					  $dbquery_up = mysql_db_query($db, $sql_up);
					  //exit();
					  //=========== ถ้ามีการแก้ไขไฟล์
					                   	if(!empty($dbquery_up))
                                             {
														$path="../picture";									 
                                                         copy($HTTP_POST_FILES['file1']['tmp_name'],"$path/$file1_name");
                                                       $sql_up = "update category set Picture='$file1_name' where CatID='$_POST[CatID]'";
                                                        $dbquery_up = mysql_db_query($db, $sql_up);
								  }
					  
									echo"<script language='JavaScript'>";
									echo"alert('แก้ไขข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";					  
			 		  }
					  
					  //===========  ถ้ามีการลบข้อมูล
						if($_GET["del"]==True)
						{
							//=========== ลบหมวด
							$sql_del= "delete from category  where CatID='$_GET[CatID]'";
							$dbquery_del = mysql_query($sql_del);
							//=========== ลบรูปภาพ
							@unlink("../picture/$_GET[filename]");
									echo"<script language='JavaScript'>";
									echo"alert('ลบข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";							
						}
						//=========== ถ้ามีการเพิ่มหมวดหมวดใหม่
						if($_POST["add"]==True)
						{
							//คำสั่งแก้ในกรณีไม่เป็นภาษาไทย
						echo "<br>";
						$sql="SELECT * FROM tbCategory";
						mysql_query("SET NAMES tis620");
								 $path="../picture";
								//=========== อัพโหลตรูปภาพ
								copy( $file1 , "$path/$file1_name" );
								//=========== บันทึกข้อมูล
								 $sql = "insert into category(CategoryName,Picture) values ('$_POST[txtCategoryName]','$file1_name')";
								 $dbquery = mysql_query($sql);
						 		
									echo"<script language='JavaScript'>";
									echo"alert('เพิ่มข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";
															 
						}					
	   
	   //=========== เอาข้อมุลมาแสดงทั้งหมด
			$sql_group = "select * from category order by CatID asc";
			$dbquery_group = mysql_query($sql_group);
			$num_rows_group = mysql_num_rows($dbquery_group);
			while ($result = mysql_fetch_array($dbquery_group))
			{
                	?>
<form name="frm<?=$i;?>" method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
  
  <table cellspacing=1 cellpadding=4 width="59%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="104" bgcolor="#FFFFFF"> <div align="center"></div>
          &nbsp; <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
    <tbody> 
    <tr bgcolor=#e5e5e5> 
      <td width="50" bgcolor="#FFFFFF"> 
        <div align="center"> 
          <input name="CatID" type="hidden" class="checkbox" id="CatID" value="<?=$result["CatID"]; ?>">
          </div>
      </td>
      <td width="440" align=middle bgcolor="#FFFFFF"> 
        <div align="left">  
          <input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="<?=$result["CategoryName"]; ?>" size="50">
                    <br>
                    จำนวนที่ต้องการให้แสดงเมื่อสินค้าใกล้หมด
                    <input name="txtCheck" type="text" class="txtbox" id="txtCheck" value="<?=$result["CheckStock"]; ?>" size="10">
                    <input type="hidden" name="update" value="True">
                    <script language="JavaScript">

function Conf<?=$result["CatID"]; ?>(object) {
if (confirm("ยืนยันการลบหมวด  [  <?=$result["CategoryName"]; ?> ] ") ==true) {
return true;
}
return false;
}

</script>
          </span><br>
                    <a href="product.php?CatID=<?=$result["CatID"];?>"><img src="../picture/<?=$result["Picture"]; ?>" width="170" height="220" border="0"></a> 
                    <br>
          แก้ไข 
          <input type="file" name="file1" class="txtbox">
                    60*60<br>
          <br>
          <table width="151" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="75"><input type="submit" name="Submit" value="บันทึกข้อมูล" class="button"></td>
              <td width="46"><div align="right"></div></td>
              <td width="30"><a href="<?=$_SERVER['PHP_SELF'];?>?CatID=<?=$result["CatID"]; ?>&filename=<?=$result["Picture"]; ?>&del=True" onClick="return Conf<?=$result["CatID"]; ?>(this)"><img src="../image/Bin.png" width="30"  height="30" border="0"onMouseOver="this.src='../image/Bin1.png';"onMouseOut="this.src='../image/Bin.png';"/></a></td>
            </tr>
          </table>
          <br>
          </div>
      </td>
      <td width="48" bgcolor="#FFFFFF"> 
        <div align="center"><a href="<?=$_SERVER['PHP_SELF'];?>?CatID=<?=$result["CatID"]; ?>&filename=<?=$result["Picture"]; ?>&del=True" onClick="return Conf<?=$result["CatID"]; ?>(this)"></a></div>
      </td>
    </tr>
    </tbody> 
  </table></td>
      </tr>
    </tbody>
  </table>
</form>
<?
	                     	$i++;
	                         	}
	                      	?>
<table cellspacing=1 cellpadding=4 width="59%" bgcolor=#9999FF border=0 align="center" height="10">
  <tbody> 
  <tr bgcolor=#e5e5e5> 
    <td width="104" bgcolor="#FFFFFF"> 
      <div align="center"><b>เพิ่มหมวดสินค้า</b> 
      </div>
      <form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="frmAdd" id="frmAdd">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="11%"><input name="add" type="hidden" id="add" value="True"></td>
            <td width="69%"> 
              <input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="ชื่อหมวด">
              <br>
                ไฟล์รูปภาพ 
                <input type="file" name="file1" class="txtbox" size="20">
                60*60 </td>
            <td width="20%">&nbsp;</td>
          </tr>
          <tr> 
            <td width="11%">&nbsp;</td>
            <td width="69%"> <br>
              <input type="submit" name="Submit2" value="เพิ่ม" class="button">
            </td>
            <td width="20%">&nbsp;</td>
          </tr>
        </table>
      </form>
      &nbsp; </td>
  </tr>
  </tbody> 
</table>
<table cellspacing=0 cellpadding=0 width="59%" 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="head.php">กลับไปหน้าหลัก</a></div></td>
            </tr>
          </tbody>
        </table></td>
    </tr>
  </tbody>
</table>





Tag : PHP, CakePHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-08-18 20:16:43 By : tormam View : 1703 Reply : 20
 

 

No. 1



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



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

ลองใช้แทน COPY ครับ
Code (PHP)
move_uploaded_file







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-18 21:18:22 By : Professer
 


 

No. 2



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



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

ไม่ได้อยู่ดีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-18 21:57:13 By : tormam
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

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

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

CHMOD 777 แล้วหรือยังครับ


Go to : chmod 777 คืออะไร php chmod 777 บน linux/unix คืออะไร ต้องเข้าไปแก้ไขที่ไหน ยังไง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-18 22:56:58 By : webmaster
 


 

No. 4



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



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

777 แล้วคับ อันนี้คือโค้ดหน้าปก อัลบั้ม สินค้าะครับ แต่ โค้ด อัพรูปสินค้ามันอัพได้แล้วนะคับ แต่โค้ดอัพรูปสินค้าต้องเอารูปเข้าไปในโฟรเดอร์ ที่โฮส ก่อน

โค้ดอัพรูป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")
	                   {
					   $file_name = $HTTP_POST_FILES['file']['name'];

						   //===========  บันทึกข้อมูลสินค้า
	                  $sql = "update product set  Picture='$file_name',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 = mysql_query($sql);
					  //echo $sql_up;
					//  exit();
					//===========  แก้ไขไฟล์เล็ก
					                   	if(!empty($dbquery_up))
                                             {
														$path="../picture";								
														//=========== อัพโหลตไฟลืเล็ก
                                                        copy($HTTP_POST_FILES['file']['tmp_name'],"$path/$file_name");
                                                       $sql = "update product set Picture='$file_name' where ProductID='$_GET[ProductID]'";
                                                       $dbquery = mysql_query($sql_update);
								 			 }
										 
					  
									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()">
  <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="true"> 
              </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"];?>" /></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>



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 09:26:50 By : tormam
 


 

No. 5



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



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

--
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 13:28:57 By : tormam
 


 

No. 6



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



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


เปลี่ยน config connect ใน host ยังครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 14:57:44 By : l3luEbirD
 


 

No. 7



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



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

ยังไงคับ งง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 15:25:25 By : tormam
 


 

No. 8



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



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


1. connect.php ใน host ที่คุณอัพขึ้นไป เปลี่ยนรึยังอะครับ

2.รูปเข้า host รึป่าวครับ หรือเข้า host แต่ไม่ลง db
หรือไม่เข้าทั้ง db ทั้ง host

3.$file1_name มาจากไหนครับ ไม่เหงค่าของตัวแปรเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 15:46:46 By : l3luEbirD
 


 

No. 9



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



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

$file1_name ก็คือในโค้ดอันแรก อะคับ ในบรรทัดที่ 137 ที่ตรง <input type="file" name="file1" class="txtbox"> โดยมันเป็นการอัฟโหลดไฟล์อะคับ จึงจะเอาแค่ชื่อของไฟล์ไปไว้ในฐานข้อมูลเลยใส่ เป็น $file1_name เพิ่ม _name ต่อท้ายไปอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 16:11:13 By : tormam
 


 

No. 10



โพสกระทู้ ( 4,720 )
บทความ ( 8 )



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


จำได้ว่ากระทู้ก่อนหน้านี้บอกวิธีเขียนที่ถูกต้องไปแล้ว แต่ก็ไม่ได้ปรับปรุงเลย แล้วยังงี้คิดว่ามันจะทำงานได้กับทุก server มั้ยครับ?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 16:17:17 By : mr.v
 


 

No. 11



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



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

คัร ผมลองแก้ แล้วคับ จากโค้ด อันแรก ตอนนี้ สามารถ อัพได้แล้วคับ แต่พอมีใครรู้บางไหมคับทำไมเราต้องเอารูปไปไว้ในไฟล์เก็บก่อนอัพรูปของโฮส ถ้าไม่เอาไป มันจะไม่สามารถอัพได้

โค้ดที่แก้เสร็จ
Code (PHP)
<?
ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
require_once('../connect/connect.php');
?>
<html>
<title>..:: ระบบจัดการฐานข้อมูล ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" href="../css/styles.css" type="text/css">
 
<div align="center"><br>
  <table cellspacing=1 cellpadding=4 width="59%" 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="head.php">กลับไปหน้าหลัก</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</div>
<?				//=========== กรณีมีการแก้ไขหมวดสินค้า
                       if($_POST["update"]==True)
	                   {
					   $file1_name = $HTTP_POST_FILES['file1']['name'];

						   //=========== บันทึกข้อมูล
	                  $sql = "update category set Picture='$file1_name',CategoryName='$_POST[txtCategoryName]',CheckStock='$_POST[txtCheck]' where CatID='$_POST[CatID]'";
                    
					//echo $sql_up ;
					  $dbquery = mysql_db_query($db, $sql);
					  //exit();
					  //=========== ถ้ามีการแก้ไขไฟล์
					                   	if(!empty($dbquery_up))
                                             {
														$path="../picture";									 
                                                         copy($HTTP_POST_FILES['file1']['tmp_name'],"$path/$file1_name");
                                                       $sql = "update category set Picture='$file1_name' where CatID='$_POST[CatID]'";
                                                        $dbquery = mysql_db_query($db, $sql);
								  }
					  
									echo"<script language='JavaScript'>";
									echo"alert('แก้ไขข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";					  
			 		  }
					  
					  //===========  ถ้ามีการลบข้อมูล
						if($_GET["del"]==True)
						{
							//=========== ลบหมวด
							$sql_del= "delete from category  where CatID='$_GET[CatID]'";
							$dbquery_del = mysql_query($sql_del);
							//=========== ลบรูปภาพ
							@unlink("../picture/$_GET[filename]");
									echo"<script language='JavaScript'>";
									echo"alert('ลบข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";							
						}
						//=========== ถ้ามีการเพิ่มหมวดหมวดใหม่
						if($_POST["add"]==True)
						{
						
								 $path="../picture";
								//=========== อัพโหลตรูปภาพ
								copy( $file1 , "$path/$file1_name" );
								//=========== บันทึกข้อมูล
								 $sql = "insert into category(CategoryName,Picture) values ('$_POST[txtCategoryName]','$file1_name')";
								 $dbquery = mysql_query($sql);
						 		
									echo"<script language='JavaScript'>";
									echo"alert('เพิ่มข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='category.php';";
									echo"</script>";
															 
						}					
	   
	   //=========== เอาข้อมุลมาแสดงทั้งหมด
			$sql_group = "select * from category order by CatID asc";
			$dbquery_group = mysql_query($sql_group);
			$num_rows_group = mysql_num_rows($dbquery_group);
			while ($result = mysql_fetch_array($dbquery_group))
			{
                	?>
<form name="frm<?=$i;?>" method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
  
  <table cellspacing=1 cellpadding=4 width="59%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="104" bgcolor="#FFFFFF"> <div align="center"></div>
          &nbsp; <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
    <tbody> 
    <tr bgcolor=#e5e5e5> 
      <td width="50" bgcolor="#FFFFFF"> 
        <div align="center"> 
          <input name="CatID" type="hidden" class="checkbox" id="CatID" value="<?=$result["CatID"]; ?>">
          </div>
      </td>
      <td width="440" align=middle bgcolor="#FFFFFF"> 
        <div align="left">  
          <input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="<?=$result["CategoryName"]; ?>" size="50">
                    <br>
                    จำนวนที่ต้องการให้แสดงเมื่อสินค้าใกล้หมด
                    <input name="txtCheck" type="text" class="txtbox" id="txtCheck" value="<?=$result["CheckStock"]; ?>" size="10">
                    <input type="hidden" name="update" value="True">
                    <script language="JavaScript">

function Conf<?=$result["CatID"]; ?>(object) {
if (confirm("ยืนยันการลบหมวด  [  <?=$result["CategoryName"]; ?> ] ") ==true) {
return true;
}
return false;
}

</script>
          </span><br>
                    <a href="product.php?CatID=<?=$result["CatID"];?>"><img src="../picture/<?=$result["Picture"]; ?>" width="170" height="220" border="0"></a> 
                    <br>
          แก้ไข 
          <input type="file" name="file1" class="txtbox">
                    60*60<br>
          <br>
          <table width="151" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="75"><input type="submit" name="Submit" value="บันทึกข้อมูล" class="button"></td>
              <td width="46"><div align="right"></div></td>
              <td width="30"><a href="<?=$_SERVER['PHP_SELF'];?>?CatID=<?=$result["CatID"]; ?>&filename=<?=$result["Picture"]; ?>&del=True" onClick="return Conf<?=$result["CatID"]; ?>(this)"><img src="../image/Bin.png" width="30"  height="30" border="0"onMouseOver="this.src='../image/Bin1.png';"onMouseOut="this.src='../image/Bin.png';"/></a></td>
            </tr>
          </table>
          <br>
          </div>
      </td>
      <td width="48" bgcolor="#FFFFFF"> 
        <div align="center"><a href="<?=$_SERVER['PHP_SELF'];?>?CatID=<?=$result["CatID"]; ?>&filename=<?=$result["Picture"]; ?>&del=True" onClick="return Conf<?=$result["CatID"]; ?>(this)"></a></div>
      </td>
    </tr>
    </tbody> 
  </table></td>
      </tr>
    </tbody>
  </table>
</form>
<?
	                     	$i++;
	                         	}
	                      	?>
<table cellspacing=1 cellpadding=4 width="59%" bgcolor=#9999FF border=0 align="center" height="10">
  <tbody> 
  <tr bgcolor=#e5e5e5> 
    <td width="104" bgcolor="#FFFFFF"> 
      <div align="center"><b>เพิ่มหมวดสินค้า</b> 
      </div>
      <form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="frmAdd" id="frmAdd">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="11%"><input name="add" type="hidden" id="add" value="True"></td>
            <td width="69%"> 
              <input name="txtCategoryName" type="text" class="txtbox" id="txtCategoryName" value="ชื่อหมวด">
              <br>
                ไฟล์รูปภาพ 
                <input type="file" name="file1" class="txtbox" size="20">
                60*60 </td>
            <td width="20%">&nbsp;</td>
          </tr>
          <tr> 
            <td width="11%">&nbsp;</td>
            <td width="69%"> <br>
              <input type="submit" name="Submit2" value="เพิ่ม" class="button">
            </td>
            <td width="20%">&nbsp;</td>
          </tr>
        </table>
      </form>
      &nbsp; </td>
  </tr>
  </tbody> 
</table>
<table cellspacing=0 cellpadding=0 width="59%" 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="head.php">กลับไปหน้าหลัก</a></div></td>
            </tr>
          </tbody>
        </table></td>
    </tr>
  </tbody>
</table>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 16:39:53 By : tormam
 


 

No. 12



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



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

ใส่ $file1_name = $HTTP_POST_FILES['file1']['name']; เพิ่มเข้าไป
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 16:40:37 By : tormam
 


 

No. 13



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



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


เอาออกมานอก if update ครับ

if add มันไม่เห็น
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 17:38:00 By : l3luEbirD
 


 

No. 14



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



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

เอา $file1_name = $HTTP_POST_FILES['file1']['name']; ออกไปนอกหรอกคับ หรือ ยังไง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 18:44:22 By : tormam
 


 

No. 15



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



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

--
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-19 19:59:46 By : tormam
 


 

No. 16

Guest


ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-22 05:39:02 By : tonkla
 


 

No. 17

Guest


อยากถาม โค๊ด แบ่งหน้าอะครับ กด next ไม่ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-22 05:54:57 By : tokla
 


 

No. 18

Guest


ตกลง หมวดหมู่สินค้าทำยังไงครับได้ช่วยบอกที


เพิ่มภาพหมวดหมู่ โดยไม่ต้องเอาภาพไปเก็บก่อนทำไงอ่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-01 21:05:01 By : tea
 


 

No. 19

Guest


กด next ไม่ได้ แงแงๆๆๆๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-01-25 15:15:24 By : พิชิตพล
 


 

No. 20



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



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


ตอนนี้เหลือแต่ upload ขึ้น host ไม่ได้ครับ (ไปขุดกระทู้เก่ามา เหลาต่อ)
Code (PHP)
     {
														$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>";			

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-10 16:56:11 By : roj
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อัฟรูป ไม่เข้าฐานข้อมูลครับอันนี้ ในเครื่ง ทำได้นะแต่ Host ไม่ได้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่