|
 |
|
บันทึกไม่ลงฐานข้อมูลค่ะ ช่วยแก้โค้ดให้หน่อยค่ะ บันทึกไม่ลงฐานข้อมูลค่ะ ช่วยแก้โค้ดให้หน่อยค่ะ |
|
 |
|
|
 |
 |
|
บันทึกไม่ลงฐานข้อมูลค่ะ ช่วยแก้โค้ดให้หน่อยค่ะ

Code (PHP)
<html>
<head>
<title>¤é¹ËÒ¢éÍÁÙÅ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<?
include("header.php");
?>
<br>
<center><b>ºÑ¹·Ö¡ÃÒ¡ÒÃàÃè§ÃÑ´</b></center>
<form name="frmSearch" method="get" action="<?=$_SERVER['PHP_SELF'];?>">
<center><table width="599" border="1">
<tr>
<th>¡ÃسÒãÊèÃËÑÊËÃ×ͪ×è;¹Ñ¡§Ò¹àÃè§ÃÑ´·Õèµéͧ¡Òà :
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
<input type="submit" value="¤é¹ËÒ"></th>
</tr>
</table> </center>
</form>
<?
if($_GET["txtKeyword"] != "" )
{
$objConnect = odbc_connect("db1","sa","PswPGe48") or die("Error Connect to Database");
$strSQL = "SELECT employee.DID, employee.DName FROM employee WHERE (employee.DName LIKE '%".$_GET["txtKeyword"]."%' or employee.DID LIKE '%".$_GET["txtKeyword"]."%' )";
$objQuery = odbc_exec($objConnect,$strSQL) or die ("Error Query [".$strSQL."]");
?>
<?
while($objResult=odbc_fetch_array($objQuery))
{
?>
<center>
<form method='get' action="<?=$_SERVER['PHP_SELF'];?>">
<input type='hidden' name='txtKeyword' value=<?=$_GET["txtKeyword"]?> >
<table width="60%">
<tr>
<td width="25%" bgcolor=#FF9999> <b>ÃËÑʾ¹Ñ¡§Ò¹ : </b></td>
<td width="75%" bgcolor=#FF9999><input type="text" name="txtDID" size="10" readonly="true" value="<?=$objResult["DID"];?>"></td>
</tr>
<tr>
<td width="25%" bgcolor=#FF9999> <b>ª×è;¹Ñ¡§Ò¹ :</b></td>
<td width="75%" bgcolor=#FF9999> <input type="text" name="txtDName" size="30" readonly="true" value="<?=$objResult["DName"];?>"></td>
</tr>
<tr>
<td width="25%" bgcolor=#FF9999> <b>àÅ¢·ÕèÊÑÒ·Õè¨èÒ : </b></td>
<td width="75%" bgcolor=#FF9999>
<input type="text" name="txtContNo" size="10" value="<?=$_GET['txtContNo']?>" >
<input type="submit" name='checkId' value="µÃǨÊͺàÅ¢·ÕèÊÑÒ" ></td>
</tr>
<?
if($_GET["txtContNo"] != "")
{
$objConnect = odbc_connect("test","sa","PswPGe48") or die("Error Connect to Database");
$strSQL = "select * from ARMAST inner join CUSTMAST on ARMAST.CUSCOD=CUSTMAST.CUSCOD where CONTNO='$_GET[txtContNo]'";
//echo $strSQL;
$objQuery = odbc_exec($objConnect,$strSQL) or die ("Error Query [".$strSQL."]");
if(odbc_num_rows($objQuery)==0) echo "äÁèÁÕàÅ¢·ÕèÊÑÒ¨èÒ¹Õé";
}
?>
<tr>
<td width="25%" bgcolor=#FF9999> <b>ª×è;¹Ñ¡§Ò¹¨èÒ§ҹ : </b></td>
<td width="75%" bgcolor=#FF9999><input type="text" name="txtName" size="30" value="<?=$_GET['txtName']?>" ></td>
</tr>
<tr>
<td width="25%" bgcolor=#FF9999> <b> Çѹ·ÕèºÑ¹·Ö¡ : </b></td>
<td width="75%" bgcolor=#FF9999><input type="text" name="txtDate" size="10"readonly="true" value = "<?=date('d-m-Y')?>"></td>
</tr>
<?
while($objResult=odbc_fetch_array($objQuery))
{
?>
<tr>
<td width="25%" bgcolor=#FF9999> <b>ÃËÑÊÅÙ¡¤éÒ : </b></td>
<td width="75%" bgcolor=#FF9999><input type="text" name="txtCusID" size="10" value="<?=$objResult["CUSCOD"];?>" ></td>
</tr>
<tr>
<td width="25%" bgcolor=#FF9999><b>ª×èÍ-Ê¡ØÅ ÅÙ¡¤éÒ : </b></td>
<td width="75%" bgcolor=#FF9999><input type="text" name="txtCusName" size="30" value="<?=$objResult["NAME1"]." "." ".$objResult["NAME2"]?>" ></td>
</tr>
<tr>
<td colspan="2" bgcolor=#FF6699>
<div align="center">
<input type="submit" value="ºÑ¹·Ö¡" >
<input type="reset" value="¡àÅÔ¡" >
</div>
</td>
</tr>
</td>
</table>
</form>
<?
$conn=odbc_connect("db1","sa","PswPGe48") or die("Error Connect to Database");
echo
$sql = "insert into save VALUES('$txtDID','$txtDName','$txtContNo','$txtName','$txtDate','$txtCusID','$txtCusName')";
//echo $sql;
odbc_execute($conn,$sql) or die("odbc_error()");
odbc_close($conn);
}
?>
<?
odbc_close($objConnect);
?>
<?
} // end isset show
?>
<?
}
?>
<body>
</html>
ลอง echo $sql ออกมาแล้ว พอดึงค่าขึ้นมาจากฐานข้อมูลก็เป็นเหมือนในรูป
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-02-18 14:26:39 |
By :
sitorn2170 |
View :
1018 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเช็คเครื่องหมาย " และ ' หรือยังครับว่าไม่ได้ใส่เกิน
|
 |
 |
 |
 |
Date :
2010-02-18 15:19:52 |
By :
krajib |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเค้า โค๊ดที่ echo ขึ้นมา ไป ใส่ลงใน SQL ใน ฐานข้อมูลโดยตรง ถ้ายังไม่ลงก็ ไล่ทีละฟิลด์เลย ไล่ไปๆ จนกว่าจะเจอตัวผิด ถ้า ลงได้ทุกตัว ก็แปลว่า่าจะมีปัญหาตรงการ connected ฐานข้อมูลแล้วอ่ะ --"
|
 |
 |
 |
 |
Date :
2010-02-18 23:42:46 |
By :
jaejai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|