ช่วยดูโค้ดอัพโหลดนี้ให้ทีค่ะ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ น่ะค่ะ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ

Moderator: phpbb, mindphp, ผู้ดูแลกระดาน

ตอบกลับโพส
I3en_jung
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 6
ลงทะเบียนเมื่อ: 01 ม.ค. 1970, 07:00

ช่วยดูโค้ดอัพโหลดนี้ให้ทีค่ะ

โพสต์ โดย I3en_jung »

มันเป็นโค้ดแก้ไขข่าวน่ะค่ะ รันผ่านทุกอย่าง แต่ว่าไม่อัพเดทลงไปในฐานข้อมูลให้ ติดต่อฐานข้อมูลถูกต้องค่ะ รบกวนด้วยนะค่ะ สำคัญมากๆ
<?
session_start();
if($_SESSION[sess_userid]<>session_id()){
header ("Location: pag_login.php"); exit();

}
$id_edit=$_POST['id_edit'];
$title=$_POST['title'];
$detail=$_POST['detail'];
$chkdel=$_POST['chkdel'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];

//mysql_db_query($dbname,$sql) or die ("failed with error message: \"" . mysql_error () . '"');
include "connection.inc.php";

if($chkdel=="1"){
$sql="update tb_new set photo_new='' where id_new='$id_edit' ";
mysql_db_query($dbname,$sql);
@unlink($photo."/".$photo_del);
}
if($photo){
$ext=strtolower(end(explode('.',$photo_name)));
if($ext=="jpg"or $ext=="jpeg"or$ext=="gif"){
$filename=$id_edit.".".$ext;
copy($photo,"photo/".$filename);
$sql="update tb_new set photo_new='$filename' where id_new='$id_edit' ";
mysql_db_query($dbname,$sql);
}
}
$sql="update tb_new set title_new='$title',detail_new='$detail',type_new='$type' where id_new='$id_edit' ";
$result=mysql_db_query($dbname,$sql);
if($result){
echo "<h3>แก้ไขข่าวเรียบร้อยแล้วค่ะ</h3>";
echo"[<a href=new_main.php>กลับหน้าหลัก</a>]";
}
else {
echo "<h3>ไม่สามารถแก้ไขข้อมูลได้</h3>";
}
echo mysql_error();
mysql_close();
?>
mindphp
phpBBThailand VIP Members
phpBBThailand VIP Members
โพสต์: 2269
ลงทะเบียนเมื่อ: 01 ม.ค. 1970, 07:00
ติดต่อ:

โพสต์ โดย mindphp »

if($ext=="jpg"or $ext=="jpeg"or$ext=="gif"){
ลองแก้เป็น
if($ext=="jpg" or $ext=="jpeg" or $ext=="gif"){
หรือ
if($ext=="jpg" || $ext=="jpeg" || $ext=="gif"){
สร้างไฟล์ pdf online
ท่องเที่ยว http://www.thailandhotelforums.com/" onclick="window.open(this.href);return false;
สอน php http://www.mindphp.com/" onclick="window.open(this.href);return false;
I3en_jung
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 6
ลงทะเบียนเมื่อ: 01 ม.ค. 1970, 07:00

โพสต์ โดย I3en_jung »

ขอบคุณค่า
ตอบกลับโพส

ย้อนกลับไปยัง

ผู้ใช้งานขณะนี้

กำลังดูบอร์ดนี้: 193 และ บุคคลทั่วไป 0 ท่าน