 |
มัน error แบบนี้อ่ะครับ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 |
|
 |
|
|
 |
 |
|
sql command ผิดอะครับ ลองเอา code มาดูสิครับ
|
 |
 |
 |
 |
Date :
2011-08-30 22:02:00 |
By :
windersun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมจะแก้ไขข้อมูลที่อยู่ในฐานข้อมูลอ่ะครับ ชื่อ ตาราง menu3_food คีคือ id3 ตารางการแก้ไขมี 3 ตารางคือ name Be รูป
ต้องเขียนฟอร์มยังไงหรอครับ ขอโค้ดหน่อยครับ ผมตันแล้วครับ
|
 |
 |
 |
 |
Date :
2011-08-30 22:04:14 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>edit</title>
</head>
<body>
<form action="edit3-1.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<?
include("connectdb.php");
$id3 = $_REQUEST["id3"];
$sql = "SELECT * FROM menu3_food ";
$rs = mysql_query($sql)or die(mysql_error());
$row = mysql_fetch_array($rs);
?>
<table width="486" border="1" align="center">
<tr>
<td colspan="2"><div align="center"><strong>แก้ไขสินค้า</strong></div></td>
</tr>
<tr>
<td width="113">name</td>
<td width="357"><label>
<div align="left">
<input type="text" name="name" value="<?=$row["name"]?>" />
</div>
</label></td>
</tr>
<tr>
<td>Be</td>
<td><label>
<textarea name="Be"><?=$row["Be"]?>
</textarea>
</label></td>
</tr>
<tr>
<td>รูป</td>
<td><label>
<div align="left">
<div></div>
<input type="file" name="pic" id="fileField" />
</div>
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="hidden" name="id3" value="<?=$id3?>" />
<input type="hidden" name="pic" value="<?=$row["pic"]?>" />
<input type="submit" name="button2" id="button2" value="Save" />
<input type="submit" name="button2" id="button2" value="Reset" />
</div>
</label></td>
</tr>
</table>
</form>
<? include("disconnectdb.php"); ?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-08-30 22:05:00 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อัพหน่อยครับ มึนไปหมดแล้ว
|
 |
 |
 |
 |
Date :
2011-08-30 22:56:05 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$rs = mysql_query($sql)or die(mysql_error());
เปลี่ยนเป็น
$rs = mysql_query($sql)or die(mysql_error() . '<br/>' . $sql);
|
 |
 |
 |
 |
Date :
2011-08-30 23:42:51 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอกด เซฟแล้วขึ้นแบบนี้อ่ะครับ
UPDATE menu3_food SET name = 'วิตามิน B1',Be = 'ช่วยบำรุงสุขภาพ และควบคุมจังหวะการเต้นของหัวใจ และยังช่วยการทำงานในระบบแปลงน้ำตาลในเลือดให้ กลายเป็นน้ำตาล เมื่อขาดวิตามิน B1 จะมีผลทำให้ปวดศรีษะ, มีปัญหาในกระเพาะอาหาร และ แขน ขา เป็นตะคริวได้ง่าย', WHERE id3 = 2
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id3 = 2' at line 1
|
 |
 |
 |
 |
Date :
2011-08-31 00:51:26 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค๊ดที่ให้มามัน select ไหงไป error ที่ update ละครับ 
|
 |
 |
 |
 |
Date :
2011-08-31 00:57:07 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้โค้ด อัพครับผิดตรงไหนช่วยทีครับพี่
<?
$id3 = $_REQUEST["id3"];
$name = $_REQUEST["name"];
$Be = $_REQUEST["Be"];
$pic = $_REQUEST["pic"];
$pic = $_FILES["pic"];
$pic_name = $pic["name"];
$pic_type = $pic["type"];
$pic_size = $pic["size"];
$pic_temp = $pic["tmp_name"];
echo "data : name = $name,Be = $Be
<br />";
echo "Picture : name = $pic_name ,"
." type = $pic_type , size = $pic_size<br />";
echo "Path : $pic_temp";
include("connectdb.php");
if($pic_name =="" ){
$sql = "UPDATE menu3_food SET name = '$name',Be = '$Be', WHERE id3 = '$id3' ";
echo $sql."<br />";
mysql_query($sql)or die (mysql_error());
}else{
unlink("images/$oldpic");
if ($pic_type == "image/gif")
$pic_type = "gif";
else if ($pic_type == "images/bmp")
$pic_type = "bmp";
else
$pic_type = "jpg";
$filename = "images/$pid.$pic_type";
move_uploaded_file($pic_temp, $filename);
$sql = "UPDATE menu3_food SET name ='$name', "
."Be = '$Be', "
."WHERE id3 = $id3 ";
echo $sql."<br />";
}
?>
|
 |
 |
 |
 |
Date :
2011-08-31 09:36:34 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ไปไหนแล้วครับ
|
 |
 |
 |
 |
Date :
2011-08-31 10:29:08 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไอ้นี่ออกครับ
$sql = "UPDATE menu3_food SET name = '$name',Be = '$Be', WHERE id3 = '$id3' ";
|
 |
 |
 |
 |
Date :
2011-08-31 10:36:43 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับพี่ ขอบคุณมากครับ นิดเดียวจิงๆ
|
 |
 |
 |
 |
Date :
2011-08-31 10:58:52 |
By :
อาทิตย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|