 |
พี่ๆครับช่วยดู Code Edit ให้ผมหน่อยว่าผมผิดตรงไหน มันขึ้นNot Succeed [UPDATE number SET location = '22H 16 AB' ,line = '09' ,primary = '' ,cab = '67' ,adsl = 'H 1-0-6-18' ,note = 'Test' WHERE numberID = '034-257532' ] |
|
 |
|
|
 |
 |
|
Code (PHP)
<html>
<head>
<title>M.D.F. Edit!</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<form action="ES.number.php?numID=<?=$_GET["numID"];?>" name="frmEdit" method="post">
<?
$objConnect = mysql_connect("localhost","root","9932") or die("Error Connect to Database");
$strSQL = "SELECT * FROM number WHERE numberID = '".$_GET["numID"]."' ";
$objDB = mysql_select_db("mdf");
mysql_query("Set Names UTF8");
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not found numberID=".$_GET["numID"];
}
else
{
?>
<table border="1">
<tr>
<th> <div align="center">Number </div></th>
<th> <div align="center">Location</div></th>
<th> <div align="center">Line</div></th>
<th> <div align="center">Primary </div></th>
<th> <div align="center">Cab</div></th>
<th> <div align="center">Adsl</div></th>
<th> <div align="center">Note</div></th>
</tr>
<tr>
<td><div align="center"><?=$objResult["numberID"];?></div></td>
<td><div align="center"><input name="location" type="text" id="location" value="<?=$objResult["location"];?>"></div></td>
<td><div align="center"><input name="line" type="text" id="line" value="<?=$objResult["line"];?>" maxlength="2"></div></td>
<td><div align="center"><input type="text" name="txtprimary" value="<?=$objResult["primary"];?>"></div></td>
<td><div align="center"><input name="cab" type="text" id="cab" value="<?=$objResult["cab"];?>" maxlength="2"></div></td>
<td><div align="center"><input name="adsl" type="text" id="adsl" value="<?=$objResult["adsl"];?>"></div></td>
<td><div align="center"><input name="note" type="text" id="note" value="<?=$objResult["note"];?>"></div></td>
</tr>
</table>
<input type="submit" name="submit" value="Save">
<?
}
mysql_close($objConnect);
?>
</form>
</body>
</html>
Code (PHP)
<html>
<head>
<title>M.D.F. Edit!</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","9932") or die("Error Connect to Database");
$objDB = mysql_select_db("mdf");
mysql_query("Set Names UTF8");
$strSQL = "UPDATE number SET ";
$strSQL .="location = '".$_POST["location"]."' ";
$strSQL .=",line = '".$_POST["line"]."' ";
$strSQL .=",primary = '".$_POST["primary"]."' ";
$strSQL .=",cab = '".$_POST["cab"]."' ";
$strSQL .=",adsl = '".$_POST["adsl"]."' ";
$strSQL .=",note = '".$_POST["note"]."' ";
$strSQL .="WHERE numberID = '".$_GET["numID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Succeed.";
}
else
{
echo "Not Succeed [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>

Tag : PHP, JavaScript, CakePHP
|
ประวัติการแก้ไข 2012-05-23 11:21:42
|
 |
 |
 |
 |
Date :
2012-05-23 11:02:30 |
By :
holmesll |
View :
856 |
Reply :
10 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
number เป็นคำสงวนรึป่าวครับ
หรือ
field ใน table ชนิดข้อมูลไม่ตรงรึป่าวครับ
|
 |
 |
 |
 |
Date :
2012-05-23 13:41:42 |
By :
rootElement@kmutnb |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
]ลองเปลี่ยน บรรทัด 19
$objQuery = mysql_query($strSQL) or die (mysql_error());
ถ้า error เดวมันจะฟ้องเองว่า ทำไม query ไม่ได้
หรือไม่คุณก็ echo $strSQL; แล้วเอาไปรันใน phpmyadmin ก็ได้
|
ประวัติการแก้ไข 2012-05-23 13:50:21
 |
 |
 |
 |
Date :
2012-05-23 13:48:36 |
By :
pumin99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งั้นลองเอา sql ไปรัน ใน phpmyadmin
UPDATE number SET
location = '22H 16 AB' ,
line = '09' ,primary = '' ,
cab = '67' ,
adsl = 'H 1-0-6-18' ,
note = 'Test' WHERE numberID = '034-257532'
ดูว่ามันฟ้องว่าไง
|
 |
 |
 |
 |
Date :
2012-05-23 13:58:46 |
By :
pumin99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นแบบนี้อะครับพี่

|
 |
 |
 |
 |
Date :
2012-05-23 14:04:45 |
By :
holmesll |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
primary คำสงวน ?
|
 |
 |
 |
 |
Date :
2012-05-23 14:05:09 |
By :
rootElement@kmutnb |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อ ครับขอบคุณครับพี่ เด๋วลองดูแปบ
|
 |
 |
 |
 |
Date :
2012-05-23 14:06:12 |
By :
holmesll |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับพี่ๆ ทุกคน ทำได้แล้วครับ
|
 |
 |
 |
 |
Date :
2012-05-23 14:08:23 |
By :
holmesll |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code
ทีนี้ก็รู้แล้วว่าผิดตรงใหน  
|
 |
 |
 |
 |
Date :
2012-05-23 14:12:40 |
By :
pumin99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
    
|
 |
 |
 |
 |
Date :
2012-05-23 14:19:44 |
By :
holmesll |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|