|
 |
|
ช่วยดูโค้ดแก้ไขนี้ให้ทีครับ รบกวนผู้รู้ช่วยด้วยนะครับ .......................... |
|
 |
|
|
 |
 |
|
คือ ถ้าเราเข้าไปแก้ไขแล้วบางช่องเราไม่ได้กรอก แต่ผมก็ echo ออกมานะครับ ทำไมมันยังเซฟเป็นค่าว่างอะครับ
Code (PHP)
<?
session_start();
include("../register/connect.php");
$upnewname ="";
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
function show_msg($msg)
{
echo'<script language="Javascript">';
echo"alert('".$msg."')";
echo'</script>';
}
if($_REQUEST["btn"]) {
if(!empty($_FILES["picture"])) {
$ints = date('YmdGis');
if($_FILES["picture"]["type"]=="image/png")
$img = "Ad".$ints.".png";
if($_FILES["picture"]["type"]=="image/gif")
$img = "Ad".$ints.".gif";
if($_FILES["picture"]["type"]=="image/pjpeg"||$_FILES["picture"]["type"]=="image/jpeg")
$img = "Ad".$ints.".jpg";
if($img!=""){
$folderpic = "../ad/" ; //ชื่อโฟลเดอร์ที่ไว้ใช้เก็บไฟล์
$max_size = 500; // จำกัดขนาดไฟล์ ค่าเป็น kb
$width=235; //ขนาดความกว้างที่ต้องการ Resize
$height=195; // ขนาดความสูงที่ต้องการ Resize
$file_size=$_FILES['picture']['size']; // ตัวแปรขนาดของไฟล์
$limit_size=1000*$max_size;
if($file_size >= $limit_size){
echo "<script language='javascript'>alert('ไฟล์ของคุณใหญ่เกินไปครับต้องมีขนาดไม่เกิน $max_size kb');</script>";
} else {
if($_FILES["picture"]["tmp_name"]){
$fileUpload=$_FILES["picture"]["tmp_name"]; // ตัวแปร temp
$fileUpload_name=$_FILES["picture"]["name"]; // ตัวแปรชื่อไฟล์
if (isset($_FILES["picture"]["name"])) { // ถ้ามีการเซทชื่อไฟล์มาให้ประมวลผลส่วนนี้
//*** ส่วนนี้คือการ Rename รูปให้เป็นวันที่ที่บันทึก ***//
$ext = strtolower(end(explode('.', $fileUpload_name)));
$dateUpFile=date("YmdHis");
$newname="Ad".$dateUpFile.".".$ext; //ชื่อไฟล์ที่กำหนดขึ้นมาใหม่ โดยใช้วันและเวลาเป็นตัวกำหนดตั้งชื่อ
$upnewname=",picture=";
//*** สร้างภาพขึ้นมาใหม่ตามนามสกุลของไฟล์เดิม ***//
$images = $fileUpload;
$size = getimagesize($images);
$img_type=strtolower(end(explode('.',$images)));
if($size[2] == 1) {
$images_orig = imagecreatefromgif($images); // GIF
} else if($size[2] == 2) {
$images_orig = imagecreatefromjpeg($images); // JPEG
}
else if($size[2] == 3) {
$images_orig = imagecreatefrompng($images); // png
}
//*** ส่วนนี้คือการ Resize รูป ***//
$photoX = imagesx($images_orig);
$photoY = imagesy($images_orig);
$images_fin = imagecreatetruecolor($width, $height);
imagecopyresampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); // ทำการ Resize ภาพ
imagegif($images_fin,"$folderpic/".$newname);
imagedestroy($images_orig);
imagedestroy($images_fin);
}else{
echo "
<script type=\"text/javascript\">
alert(\"ไม่ใช่ไฟล์ jpg/png/gif โปรดแก้ไข\");history.back(-1);
</script>
";
exit();
}
}
}
}
}
$_SESSION["link"]= $_REQUEST['link'];
$_SESSION["vdo"]= $_REQUEST['vdo'];
$sql="UPDATE js_ad SET link='".$_REQUEST["link"]."',vdo='".$_REQUEST['vdo']."' {$upnewname}'$newname' WHERE id = 1";
mysql_query($sql) or die(mysql_error());
show_msg("ท่านได้ทำการบันทึกเรียบร้อยแล้ว");
echo "<meta http-equiv='refresh' content='0;URL=http://www.xxx.com'>";
}else{
show_msg("ผิดพลาด กรุณาทำรายการใหม่อีกครั้ง!!");
echo "<meta http-equiv='refresh' content='0;URL=http://www.xxx.com'>";
}
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-08-31 11:20:32 |
By :
l3alLkisS |
View :
923 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้กรอก มันก็ใส่ค่าว่าง ผมว่ามันก็ ถูก แล้วน่ะครับ
แต่ถ้าไม่อยากให้เก็บค่าวาง ก็ใช้ if filter ค่าว่างก่อนการ insert, update ครับ
|
 |
 |
 |
 |
Date :
2012-08-31 11:49:01 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|