มันขึ้น error ในหน้า edit เมื่อคลิกตกลงแล้ว you have and error in your sql syntax. Check the manual that corresponds toyour my sql server v
มันขึ้น error ในหน้า edit เมื่อคลิกตกลงแล้ว
error ไม่สามารถแก้ไขข้อมูลได้ you have and error in your sql syntax. Check the manual that corresponds toyour my sql server version for the right syntex to use near at line 1;:ซึ่งใน code ก้อเหมือนกับอันที่สามารถแก้ไขได้แล้ว
หน้า sql.php
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<?
session_start();
include("../../config.inc.php");
include("function.inc.php");
//VALID_USER();
//$qIp=$_SERVER['REMOTE_ADDR'];
if($command=="ADDPRODUCT" && $pDetail<>""){
if ($pPic!="") {
$name=$HTTP_POST_FILES['pPic']['name'];
$realname =date("dmYs").$name;
if (copy ($HTTP_POST_FILES['pPic']['tmp_name'],"file/$name")) {
}
}
$sql="INSERT INTO product SET pTopic='$pTopic',pType='1',pSize='$pSize',pAddress='$pAddress',pDetail='$pDetail',pPrice='$pPrice',pTel='$pTel',pName='ที่ดิน',pIp='$pIp',pDate=NOW(),pPic='$realname'";
$query=mysql_query($sql);
if($query){
showMessage("เพิ่มข้อมูลเรียบร้อยแล้ว", "listadmin.php");
}else{
showMessage("Error !!!! ไม่สามารถเพิ่มข้อมูลได้", "listadmin.php");
}
}else if($command=="EDIT" && $pDetail<>""){
if ($qPic!="") {
//@unlink("file/$old_file");
$name=$HTTP_POST_FILES['pPic']['name'];
$realname =date("dmYs").$name;
if (copy ($HTTP_POST_FILES['pPic']['tmp_name'],"file/$name")) {
$update_="pPic='$realname', ";
}
}
$sql="UPDATE product SET $update_ pTopic='$pTopic',pType='1',pSize='$pSize',pAddress='$pAddress',pDetail='$pDetail',pPrice='$pPrice',pTel='$pTel',pName='$ที่ดิน',pIp='$pIp',pDate=NOW() WHERE pId=$pId";
$query=mysql_query($sql);
if($query){
showMessage("แก้ไขข้อมูลเรียบร้อยแล้ว", "listadmin.php");
}else{
showMessage("Error !!!! ไม่สามารถแก้ไขข้อมูลได้".mysql_error(), "listadmin.php");
}
}else if($command=="Y" || $command=="N"){
$sql="UPDATE product SET pShow='$command' WHERE pId=$id";
$query=mysql_query($sql);
if($query){
showMessage("แก้ไขข้อมูลเรียบร้อยแล้ว", "listadmin.php");
}else{
showMessage("Error !!!! ไม่สามารถแก้ไขข้อมูลได้", "listadmin.php");
}
}else{
showMessage("คุณไม่มีสิทธิ์ใช้งานในส่วนนี้", "index.php");
}
?>
หน้า edit.php
<?
session_start();
include("../../config.inc.php");
include("function.inc.php");
VALID_USER();
$sql="SELECT * FROM product WHERE pId='$pId'";
$query = mysql_query($sql);
$row=mysql_fetch_array($query);
$pId=$row['pId'];
$pTopis=$row['pTopic'];
$pType=$row['pType'];
$pPic=$row['pPic'];
$pSize=$row['pSize'];
$pAddress=$row['pAddress'];
$pDetail=$row['pDetail'];
$pPrice=$row['pPrice'];
$pTel=$row['pTel'];
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<LINK rel="stylesheet" href="../css/style.css">
<title>จัดการที่ดิน</title>
<table width="820" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="800">
<? include "../inc/Header.php" ?>
</td>
</tr>
</table>
<TABLE WIDTH=820 height="340" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 bgcolor="#FFFFFF">
<TR>
<TD width="186" height="340" valign="top" bgcolor="#FFFFFF"> <div align="center">
<table width="200" height="299" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="137">
<? include "../inc/left.php" ?>
</td>
</tr>
</table>
</div></TD>
<TD width="600" valign="top" bgcolor="#FFFFFF"><table width="570" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="340">
<form action="sql.php" method="post" enctype="multipart/form-data" name="checkForm" onSubmit="return check()">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> <TABLE width="570" height="165" border=0 align="center">
<TR>
<TD height="9" colspan="2" align=middle bgcolor="#CCFFCC"><div align="right">
<font color="#000000"> </font> </div>
<div align="center"><font color="#000000" size="3"><strong>แก้ไขข้อมูล</strong></font></div></TD>
</TR>
<TR>
<TD height="0" colspan="2" align=middle> </TD>
</TR>
<TR>
<TD height="0" align=middle><div align="left"><font color="#333333" size="2"><strong> <img src="../icon/newsbullet.gif" width="6" height="7">
หัวข้อ:</strong></font></div></TD>
<TD height="0" align=middle><div align="justify"><font color="#FF0000">
<input name="pTopic" type="text" class="box" id="pTopic" value="<? echo $row['pTopic'] ?>" size="40">
</font></div></TD>
</TR>
<TR>
<TD align=middle><div align="left"><font color="#333333" size="2"><strong> <img src="../icon/newsbullet.gif" width="6" height="7">
รูปประกอบ :</strong></font></div></TD>
<TD align=middle> <div align="justify">
<input name="pPic" type="file" id="pPic2">
<font color="#FF0000"> </font> </div></TD>
</TR>
<TR>
<TD width="20%" height="29" align=middle><div align="left"><font color="#333333" size="2"><strong> <img src="../icon/newsbullet.gif" width="6" height="7">
จำนวน :</strong></font></div></TD>
<TD width="80%" align=middle> <div align="justify"><font color="#FF0000">
<input name="pSize" type="text" class="box" id="pSize" value="<? echo $row['pSize'] ?>" size="40">
</font></div></TD>
</TR>
<TR>
<TD height="4" align=middle valign="top"><div align="left"><font color="#333333" size="2"><strong> <img src="../icon/newsbullet.gif" width="6" height="7">
ทำเลที่ตั้ง :</strong></font></div></TD>
<TD width="80%" align=middle><div align="justify"><font color="#FF0000">
<input name="pAddress" type="text" class="box" id="pAddress" value="<? echo $row['pAddress'] ?>" size="40">
</font></div></TD>
</TR>
<TR>
<TD height="5" align=middle valign="top"><div align="left"><font color="#333333"> <img src="../icon/newsbullet.gif" width="6" height="7">
<font size="2"><strong>รายละเอียด</strong></font><strong>
:</strong></font></div></TD>
<TD width="80%" align=middle> <div align="justify">
<textarea name="pDetail" cols="70" rows="10" id="pDetail"><? echo $row['pDetail'] ?></textarea>
</div></TD>
</TR>
<TR>
<TD height="11" align=middle valign="top"><div align="left"><font color="#333333"> <img src="../icon/newsbullet.gif" width="6" height="7">
<strong><font size="2">ราคา :</font></strong> </font></div></TD>
<TD width="80%" align=middle><div align="justify"><font color="#FF0000">
<input name="pPrice" type="text" class="box" id="pPrice" value="<? echo $row['pPrice'] ?>" size="40">
</font></div></TD>
</TR>
<TR>
<TD height="11" align=middle valign="top"><div align="left"><font color="#333333"> <img src="../icon/newsbullet.gif" width="6" height="7">
<strong><font size="2">สนใจติดต่อ :</font></strong>
</font></div></TD>
<TD width="80%" align=middle><div align="justify"><font color="#FF0000">
<input name="pTel" type="text" class="box" id="pTel" value="<? echo $row['pTel'] ?>" size="40">
</font></div></TD>
</TR>
<TR>
<TD align=middle valign="top"> </TD>
<TD align=middle><div align="left">
<input name="command" type="hidden" id="command2" value="EDIT">
<input name="id" type="hidden" id="command3" value="<? echo $pId ?>">
<input type="submit" name="Submit" value="ตกลง">
<input type="reset" name="Submit2" value="ยกเลิก">
</div></TD>
</TR>
</TABLE></td>
</tr>
</table>
</form>
<p> </p></td>
</tr>
</table></TD>
</TR>
</TABLE>
<script language="javascript">
function CheckAll() {
for (var i = 0; i < document.delForm.elements.length; i++) {
if(document.delForm.elements.type == 'checkbox'){
document.delForm.elements.checked = true;
}
}
}
function unCheckAll() {
for (var i = 0; i < document.delForm.elements.length; i++) {
if(document.delForm.elements.type == 'checkbox'){
document.delForm.elements.checked = false;
}
}
}
</script>
Tag : - - - -
Date :
29 พ.ย. 2550 13:21:11
By :
ฝน
View :
1541
Reply :
3
$sql="INSERT INTO product SET บรรทัดนี้มันผิดนะครับ insert ไม่มี set นะ
Date :
29 พ.ย. 2550 13:31:36
By :
ravatna
น่าจะเป็น
update product set แทนนะ
Date :
29 พ.ย. 2550 13:33:18
By :
ravatna
$sql="UPDATE product SET $update_ pTopic='$pTopic',pType='1',pSize='$pSize',pAddress='$pAddress',pDetail='$pDetail',pPrice='$pPrice',pTel='$pTel',pName='$ที่ดิน' ,pIp='$pIp',pDate=NOW() WHERE pId=$pId";
$query=mysql_query($sql);
if($query){
showMessage("แก้ไขข้อมูลเรียบร้อยแล้ว", "listadmin.php");
}else{
showMessage("Error !!!! ไม่สามารถแก้ไขข้อมูลได้".mysql_error(), "listadmin.php");
}
ตัวแดง ๆ นั่นหรือเปล่าหว่า....
Date :
29 พ.ย. 2550 13:43:30
By :
หนุ่มคุง
Load balance : Server 00