Warning: imagecopyresized(): supplied argument is not a valid Image resource in on line 136
Warning: imagecopyresized(): supplied argument is not a valid Image resource in /home/homeofartp/domains/homeofartphuket.com/public_html/admin_product_add2.php on line 136
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/homeofartp/domains/homeofartphuket.com/public_html/admin_product_add2.php on line 146
อันเก่าแก้ได้แระอันใหม่มาอีก แต่ว่าบันทึกลงฐานข้อมูลนะแต่ไม่รุ้ว่าติดไร รบกวนผู้รู้ด้วยน๊า
Code
<?
session_start();
if ($sess_adminid<>session_id()) {
header( "Location: admin.php"); exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.homeofartphuket.com</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style2 {
font-size: 12px;
color: #FFFFFF;
}
.style6 {color: #000000; }
.style7 {color: #FFFFFF}
-->
</style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('Asset/test1.png','Asset/HeadLogo2.png')">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="197" height="121" bgcolor="#000000"> </td>
<td colspan="3" align="center" valign="middle"><p class="style6">Discover your potential of art in your life,welcome to "Home of Art"<span class="style6">,you will have much fun and full of surprise!</span><br />
<a href="www.homeofartphuket.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Asset/HeadLogo2.png',1)"><img src="Asset/Logo1.png" alt="Logo" name="Image8" width="264" height="74" border="0" id="Image8" /></a></p> </td>
</tr>
<tr>
<td height="170" colspan="4"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','Asset/test1.png',1)"><img src="Asset/test.png" alt="www.homeofartphuket.com" name="Image7" width="100%" height="295" border="0" id="Image7" /></a><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Asset/test1.png',1)"></a></td>
</tr>
<tr>
<td height="34" bgcolor="#000000"><h3><img src="Asset/arrow.png" width="16" height="13" border="0" usemap="#Map" /><span class="style7"><a href="index.html">Home</a></span></h3></td>
<td width="755" colspan="3" rowspan="7" valign="top"><!-- InstanceBeginEditable name="EditRegion1" -->
<?
$name=$_POST[name];
$ref_id_type=$_POST[ref_id_type];
$detail=$_POST[detail];
$price=$_POST[price];
$fileupload=$_FILES['fileupload']['tmp_name'];
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];
if ($name=="") {
echo "<H3>ERROR : กรุณากรอก ชื่อสินค้า</H3>";
exit();
} else if ($ref_id_type=="0") {
echo "<H3>ERROR : กรุณาเลือก ประเภทสินค้า </H3>";
exit();
} else if ($detail=="") {
echo "<H3>ERROR : กรุณากรอก รายละเอียด </H3>";
exit();
} else if ($price=="") {
echo "<H3>ERROR : กรุณากรอก ราคาสินค้า </H3>";
exit();
}
include "connect.php";
$sql="INSERT INTO tb_product values('','$name','$ref_id_type','$detail','$price','') ";
$result=mysql_db_query($dbname,$sql);
if ($fileupload) {
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]) ;
if ($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg"or $lastname=="png") {
$sql2="select max(id_prd) from tb_product ";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$row[0].".".$lastname;
copy($fileupload,"photo/".$photoname);
/*copy($_FILES['fileupload']['tmp_name'],"php_pic/pic/".$_FILES['fileupload']['name']);*/
if ($ext =="jpg" or $ext =="jpeg") {
$ori_img = imagecreatefromjpeg($fileupload);
} else if ($ext =="png") {
$ori_img = imagecreatefrompng($fileupload);
} else if ($ext =="gif") {
$ori_img = imagecreatefromgif($fileupload);
}
$ori_size = getimagesize($fileupload);
$ori_w = $ori_size[0];
$ori_h = $ori_size[1];
if ($ori_w>=$ori_h) {
$new_w = 100;
$new_h = round(($new_w/$ori_w) * $ori_h);
} else {
$new_h =100;
$new_w = round(($new_h/$ori_h) * $ori_w);
}
$new_img= imagecreatetruecolor($new_w, $new_h);
imagecopyresized( $new_img, $ori_img,0,0,0,0,$new_w, $new_h,$ori_w,$ori_h);
if ($ext =="jpg" or $ext =="jpeg") {
imagejpeg($new_img,"images_small/$photoname");
} else if ($ext =="png") {
imagepng($new_img,"images_small/$photoname");
} else if ($ext =="gif") {
imagegif($new_img,"images_small/$photoname");
}
imagedestroy($ori_img);
imagedestroy($new_img);
/*$sql="update tb_photo set name_photo='$filename' where id_photo='$id_max' ";
mysql_db_query($dbname,$sql);*/
$sql3="update tb_product set photo_prd='$photoname' where id_prd ='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
echo "<H3>เพิ่ม สินค้าเรียบร้อยแล้ว</H3>";
echo "[ <A HREF=admin_product.php>กลับหน้าหลัก</A> ] ";
mysql_close();
?>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td height="34" bgcolor="#000000"><h3><img src="Asset/arrow.png" alt="" width="16" height="13" /><span class="style7"><a href="gallery_idex.php">Gallery</a></span></h3></td>
</tr>
<tr>
<td height="32" bgcolor="#000000"><h3><img src="Asset/arrow.png" alt="" width="16" height="13" /><span class="style7">Teaching</span></h3></td>
</tr>
<tr>
<td height="34" bgcolor="#000000"><h3><img src="Asset/arrow.png" alt="" width="16" height="13" /><span class="style7">Order</span></h3></td>
</tr>
<tr>
<td height="36" bgcolor="#000000"><h3><img src="Asset/arrow.png" alt="" width="16" height="13" /><span class="style7">Contact us</span></h3></td>
</tr>
<tr>
<td height="123" bgcolor="#000000"> </td>
</tr>
<tr>
<td height="19" bgcolor="#000000"> </td>
</tr>
<tr>
<td bgcolor="#000000"></td>
<td colspan="3" bgcolor="#B7B7B7"><p class="style2"> Copyright © 2011 Home of Art Phuket. All Rights Reserved. </p>
<p class="style2"> Home of Art (Surin Beach) 20 Srisuntorn road,Chengtalay, Thalang, Phuket,Thailand | Tel +66(0)8547 67714</p></td>
</tr>
</table>
<map name="Map" id="Map"><area shape="rect" coords="15,9,51,18" href="#" />
</map></body>
<!-- InstanceEnd --></html>
Tag : PHP, MySQL, HTML/CSS, Ajax, CakePHP, C#
Date :
2011-06-05 13:41:02
By :
rakissara
View :
973
Reply :
2
Date :
2011-06-05 13:58:28
By :
TITIPORN
น่าจะหา Source ไฟล์ไม่เจอครับ
Date :
2011-06-05 17:37:17
By :
webmaster
Load balance : Server 01