|
|
|
สอบถามหน่อยครับ เวลาอัพข้อมูลแล้วข้อมูลไม่ยอมลงฐานข้อมูล ต้องไปแก้ไขอีกครั้งถึงจะยอมลงฐานข้อมูล วานพี่ๆช่วยทีครับ |
|
|
|
|
|
|
|
อัพโหลข้อมูลแล้ว ข้อมูลไม่ยอมลงฐานข้อมูล วานพี่ๆช่วยหน่อยครับ ว่าเกิดจากสาเหตุใด
หน้า new_add
Code (PHP)
<?
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header( "Location: admin.php"); exit();
}
?>
<HTML>
<HEAD><TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(images/bgall.gif);
background-repeat: repeat-x;
background-color: #BDE5F0;
}
.style49 {font-family: "TH K2D July8";
font-size: 16px;
}
.style53 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FF0000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style112 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
color: #0000FF;
}
.style125 {
font-size: 14px;
font-family: Verdana, Geneva, sans-serif;
}
.style127 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #FF0000; }
.style134 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; }
-->
</style></HEAD>
<BODY>
<table width="1024" height="984" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<th height="982" align="center" valign="top" scope="col"><table width="1024" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="127" scope="col"><img src="../images/logonew.jpg" width="1024" height="300"></th>
</tr>
</table>
<table width="1024" height="689" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="689" valign="top" scope="col">
<br />
<?
$title=$_POST['title'];
$detail=$_POST['detail'];
$type=$_POST['type'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
$file=$_FILES['file']['tmp_name'];
$file_name=$_FILES['file']['name'];
$file_size=$_FILES['file']['size'];
$file_type=$_FILES['file']['type'];
$date_today=date("Y-m-d");
$time_today=date("H:i:s");
if ($title=="" or $detail=="" or $type=="0") {
echo "<H2> กรอกข้อมูลไม่ครบ </H2>";
exit();
}
include "connect.php";
$sql="INSERT INTO tb_new VALUES('','$title','$detail','$type','','','$date_today','$time_today')";
mysql_query("set names tis620");
mysql_db_query("$dbname",$sql);
$ext = strtolower(end(explode('.', $photo_name)));
if ($ext == "jpg" or $ext == "jpeg" or $ext=="gif") {
$sql="select max(id_new) from tb_new";
$result=mysql_db_query($dbname,$sql);
$r=mysql_fetch_array($result);
$id_max=$r[0];
$filename=$id_max.".".$ext;
copy($photo,"photo/$filename");
$sql="update tb_new set photo_new='$filename' where id_new='$id_max' ";
}
$ext2 = strtolower(end(explode('.', $file_name)));
if ($ext2 == "pdf" or $ext2 == "zip" or $ext2=="xlsx" or $ext2=="docx" or $ext2=="xls" or $ext2=="doc" or $ext2=="rar") {
$sql="select max(id_new) from tb_new";
$result=mysql_db_query($dbname,$sql);
$r=mysql_fetch_array($result);
$id_max=$r[0];
$filename=$id_max.".".$ext2;
copy($file,"file/$filename2");
$sql="update tb_new set file_new='$filename2' where id_new='$id_max' ";
mysql_db_query($dbname,$sql);
}
echo "<H3>เพิ่มข้อมูลเรียบร้อย</H3>";
echo "[ <A HREF=new_main.php>กลับหน้าหลัก</A> ] ";
mysql_close();
?>
<br>
<br></th>
</tr>
</table>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"><img src="../images/down.jpg" width="1024" height="150"></th>
</tr>
</table></th>
</tr>
</table>
</BODY>
</HTML>
ถ้าไปแก้ไขข้อมูลที่หน้าำ edit ข้อมูลถึงจะยอมลงฐานข้อมูล
หน้า edit
<?
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header( "Location: admin.php"); exit();
}
$id_edit=$_GET[id_edit];
include "function.php";
include "connect.php";
$sql="select * from tb_new where id_new='$id_edit'";
$result=mysql_db_query($dbname,$sql);
$r=mysql_fetch_array($result);
$id_new=$r[id_new];
$title_new=$r[title_new];
$type_new=$r[type_new];
$detail_new=$r[detail_new];
$photo_new=$r[photo_new];
$file_new=$r[file_new];
?>
<HTML>
<HEAD><TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(images/bgall.gif);
background-repeat: repeat-x;
background-color: #BDE5F0;
}
.style49 {font-family: "TH K2D July8";
font-size: 16px;
}
.style53 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FF0000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style112 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
color: #0000FF;
}
.style125 {
font-size: 14px;
font-family: Verdana, Geneva, sans-serif;
}
.style127 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #FF0000; }
.style134 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; }
-->
</style></HEAD>
<BODY>
<table width="1024" height="984" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<th height="982" align="center" valign="top" scope="col"><table width="1024" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="127" scope="col"><img src="../images/logonew.jpg" width="1024" height="300"></th>
</tr>
</table>
<table width="1024" height="689" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="689" align="center" valign="top" scope="col">
<H2><br>
แก้ไขข่าวสาร</H2>
<FORM ACTION="new_edit2.php" METHOD="POST" ENCTYPE="multipart/form-data">
<TABLE>
<TR>
<TD width="94"><B>หัวข้อข่าว : </B></TD>
<TD width="354"><INPUT NAME="title" TYPE="text" SIZE="50" VALUE="<?=$title_new?>"> *</TD>
</TR>
<TR>
<TD><B>ประเภท : </B></TD>
<TD>
<SELECT NAME="type">
<OPTION VALUE="0">-- เลือก -- </OPTION>
<?
for ($i=1;$i<=count($newtype);$i++) {
if ($type_new==$i) {
echo "<OPTION VALUE='$i' SELECTED>$newtype[$i]</OPTION>";
} else {
echo "<OPTION VALUE='$i' >$newtype[$i]</OPTION>";
}
}
?>
</SELECT> *
</TD>
</TR>
<TR>
<TD VALIGN="top"><B>เนื้อหา :</B></TD>
<TD><TEXTAREA NAME="detail" COLS="55" ROWS="8"><?=$detail_new?></TEXTAREA>*</TD>
</TR>
<TR>
<TD VALIGN="top"><B>รูปภาพ :</B></TD>
<TD>
<?
if ($photo_new) {
echo "<INPUT TYPE='checkbox' NAME='chkdel' VALUE='1'> ลบรูปภาพ ";
echo "<A HREF='photo/$photo_new' TARGET='_blank'> แสดงรูปภาพ </A><BR>";
} else {
echo "<INPUT NAME='photo' TYPE='file' ><BR>";
}
?>
</TD>
</TR>
<TR>
<TD><B>ไฟล์เอกสาร :</B></TD>
<TD><?
if ($file_new) {
echo "<INPUT TYPE='checkbox' NAME='chkdel2' VALUE='1'> ลบไฟล์ ";
echo "<A HREF='file/$file_new' TARGET='_blank'> แสดงไฟล์ </A><BR>";
} else {
echo "<INPUT NAME='file' TYPE='file' ><BR>";
}
?></TD>
</TR>
<TR>
<TD>
<INPUT TYPE="hidden" NAME='id_edit' VALUE="<?=$id_edit?>">
<INPUT NAME="photo_del" TYPE="hidden" VALUE="<?=$photo_new?>">
<INPUT NAME="file_del" TYPE="hidden" VALUE="<?=$file_new?>">
</TD>
<TD><INPUT TYPE="Submit" VALUE="Submit">
<INPUT TYPE="Reset" VALUE="Reset"> </TD>
</TR>
</TABLE>
</FORM>
[ <A HREF="new_main.php">กลับหน้าหลัก</A> ]
<br>
<br></th>
</tr>
</table>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"><img src="../images/down.jpg" width="1024" height="150"></th>
</tr>
</table></th>
</tr>
</table>
</BODY>
</HTML>
หน้า edit2
<?
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header( "Location: admin.php"); exit();
}
$id_edit=$_POST['id_edit'];
$title=$_POST['title'];
$detail=$_POST['detail'];
$chkdel=$_POST['chkdel'];
$chkdel2=$_POST['chkdel2'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
$file=$_FILES['file']['tmp_name'];
$file_name=$_FILES['file']['name'];
$file_size=$_FILES['file']['size'];
$file_type=$_FILES['file']['type'];
?>
<HTML>
<HEAD><TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(images/bgall.gif);
background-repeat: repeat-x;
background-color: #BDE5F0;
}
.style49 {font-family: "TH K2D July8";
font-size: 16px;
}
.style53 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FF0000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style112 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
color: #0000FF;
}
.style125 {
font-size: 14px;
font-family: Verdana, Geneva, sans-serif;
}
.style127 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #FF0000; }
.style134 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; }
-->
</style></HEAD>
<BODY>
<table width="1024" height="984" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<th height="982" align="center" valign="top" scope="col"><table width="1024" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="127" scope="col"><img src="../images/logonew.jpg" width="1024" height="300"></th>
</tr>
</table>
<table width="1024" height="689" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="689" valign="top" scope="col"><br />
<?
include "connect.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);
}
}
//แก้ไขไฟล์
if ($chkdel2=="1") {
$sql="update tb_new set file_new='' where id_new ='$id_edit' ";
mysql_db_query($dbname,$sql);
unlink("file/$file_del");
}
if ($file) {
$ext2 = strtolower(end(explode('.', $file_name)));
if ($ext2 == "pdf" or $ext2 == "zip" or $ext2=="xlsx" or $ext2=="docx" or $ext2=="xls" or $ext2=="doc" or $ext2=="rar") {
$filename=$id_edit.".".$ext2;
copy($file,"file/$filename");
$sql="update tb_new set file_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>";
}
mysql_close();
?>
<br>
<br></th>
</tr>
</table>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"><img src="../images/down.jpg" width="1024" height="150"></th>
</tr>
</table></th>
</tr>
</table>
</BODY>
</HTML>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-03-15 11:26:27
|
|
|
|
|
Date :
2013-03-15 11:25:20 |
By :
jatuphol09 |
View :
655 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ข้อความลงหมด ยกเว้น photo กับ file ที่ไม่ยอมลงฐานข้อมูลครับ ปรับเป็น 777 แล้ว แต่ยังไม่ลงครับ
|
|
|
|
|
Date :
2013-03-15 11:33:02 |
By :
jatuphol09 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยาวมากมาย เอาที่เห็นนะครับ
$filename2
มายังไงเหรอ ที่เห็นคือ
/$filename อันนี้ไม่ใช่เหรอครับ แก้ชื่อ file ครับ
|
|
|
|
|
Date :
2013-03-15 11:48:08 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|