รบกวนผู้เชี่ยวชาญช่วยชี้แนะครับ ติด Error ตรงinsert
<!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=windows-874" />
<title>ใบสั่งซื้อวัตถุดิบ</title>
<style type="text/css">
<!--
.style1 {font-family: AngsanaUPC}
#apDiv1 {
position:absolute;
left:667px;
top:231px;
width:319px;
height:104px;
z-index:1;
}
-->
</style>
</head>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<body>
<fieldset>
<legend><span class="style1">ใบสั่งซื้อวัตถุดิบ</span></legend>
<?php include('head.php'); ?>
<?php
include("config.inc.php");
//require_once('funtion.php');
require_once('includes.php');
$sql="
Select Case When Max(Purorder_ID) Is Null Then Concat('SW', Year(Now()) +543,'-01')
Else Concat(Left(Max(Purorder_ID), 7), Case When Right(Max(Purorder_ID), 2) > 8 Then Right(Max(Purorder_ID), 2) + 1
Else Concat('0', Right(Max(Purorder_ID), 1) + 1)
End)
End As Purorder_ID
From purchaseorder
Where Year(Pur_Date) = Year(Now())";
$result = mysql_query($sql);
$row=mysql_fetch_array($result);
?>
<?php
include("config.inc.php");
//require_once('funtion.php');
require_once('includes.php');
// บันทึกรายการการสั่งซื้อวัตถุดิบ
//$User = $_SESSION["sess_userid"];
$Now = date("Y-m-d H:i:s"); // หาวัน/เวลาปัจจุบัน โดยจัดรูปแบบตามที่ MySQL กำหนด
if($_POST['action']=='insert') // การเพิ่มข้อมูล
{
echo $sql_insert_1 = "
insert into purchaseorder ('Purorder_ID','Pur_Date') Values ($_POST['textfield'],$_POST['textfield2'])"
//echo $sql_insert_1;
mysql_query($sql_insert_1, $conn);
foreach($_POST['numofmaterial'] as $id => $nummaterial) {
$sql_insert_2 = "insert into detailpurchaseorder (Purorder_ID, Mat_ID, Mat_Price, Number) select max(Purorder_ID), '" . $id . "', '" . $_POST['productprice'][$id] . "', '" . $nummaterial . "' from purchaseorder";
//echo $sql_insert_2;
mysql_query($sql_insert_2, $conn);
}
echo"<script>alert('บันทึกข้อมูลใบสั่งซื้อสินค้าเรียบร้อยแล้ว');location='view_purchase_order.php';</script>";
}
?>
<script type="text/javascript" >
function openMeterialSearch() {
var screenh = screen.height;
var screenw = screen.width;
var popupw = 500;
var popuph = 450;
var left = ((screenw - popupw) / 2);
var top = ((screenh - popuph) / 2);
window.open("frmGetMaterial1.php", "MaterialSearch", "border=1, width=" + popupw + ", height=" + popuph + ", top=" + top + ", left=" + left + ",resizable=0,scrollbars=0,location=0");
}
function order(Mat_ID, Mat_Name, Mat_Price) {
//alert(Mat_ID);
if (checkItemAdd(Mat_ID)) {
var obj = document.getElementById("tablematerial");
var objRows = obj.rows.length - 2 ;
var obj = document.getElementById("tablematerial").insertRow(objRows);
obj.id = 'materialrow' + Mat_ID;
var delicon = obj.insertCell(0);
var pid = obj.insertCell(1);
var pname = obj.insertCell(2);
var pprice = obj.insertCell(3);
var pnum = obj.insertCell(4);
var psum = obj.insertCell(5);
delicon.innerHTML = '<a alt="ลบรายการนี้" title="ลบรายการนี้" href="javascript:delMaterial(' + Mat_ID + ')" ><img src="images/icon/Delete_16.png" alt="ลบ"/></a>';
delicon.align = "center" ;
pid.innerHTML = objRows + '<input type="hidden" name="Mat_ID[' + Mat_ID + ']" id="Mat_ID' + Mat_ID + '" value="' + Mat_ID + '" size="5" />';
pid.align = "center";
pname.innerHTML = Mat_Name;
pname.align = "left";
pprice.innerHTML = Mat_Price + '<input type="hidden" name="Mat_Price" Mat_ID="' + Mat_ID + '" value="' + Mat_Price + '" /><input type="hidden" name="materialprice[' + Mat_ID + ']" id="materialprice[' + Mat_ID + ']" value="' + Mat_Price + '" />';
pprice.align = "right";
pnum.innerHTML = '<input type="text" size="5" class="required" style="text-align: center;" id="numofmaterial[' + Mat_ID + ']" name="numofmaterial[' + Mat_ID + ']" onblur="processprice(this.value, ' + Mat_Price + ', \'' + Mat_ID + '\');" />';
pnum.align = "center";
psum.innerHTML = '<span id="summaterial' + Mat_ID + '" > </span>';
psum.align = "right";
phaseValidate();
}
else {
alert("มีการเลือกวัตถุดิบชิ้นนี้ไปแล้ว");
}
}
function processprice(numofmaterial, Mat_Price, targetObj) {
//alert(numofmaterial + ' ' + Price + ' ' + targetObj);
var obj = document.getElementById("summaterial" + targetObj);
obj.innerHTML = ( numofmaterial * Mat_Price );
processSumPrice();
}
function processSumPrice(){
var material = document.getElementsByName("Mat_Price");
var sumprice = 0;
//alert(material.length);
for( var i = 0; i < material.length; ++i ) {
//alert(material[i].getAttribute("Mat_ID"));
sumprice = sumprice + ((document.getElementById("numofmaterial[" + material[i].getAttribute("Mat_ID") + "]").value) * (material[i].value));
}
var obj = document.getElementById("sumprice");
obj.innerHTML = sumprice;
}
function delMaterial(objTable) {
//document.getElementById("tablematerial").deleteRow(objTable);
//alert($(target).html());
var target = "#materialrow" + objTable;
$(target).remove();
processSumPrice();
}
function checkItemAdd(Mat_ID) {
var tb = document.getElementById("tablematerial");
var idrow = "materialrow" + Mat_ID;
for (var i = 0; i < tb.rows.length ; ++i ) {
if (tb.rows[i].id == idrow)
{
return false;
}
}
return true;
}
</script>
<form name="forminput" id="forminput" method="post" action="" >
<table width="34%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="34%"><span class="style1">หมายเลขใบสั่งซื้อ</span></td>
<td width="66%"><span class="style1">
<label>
<input name="textfield" type="text" id="textfield" value="<? echo $row["Purorder_ID"]; ?>" readonly=readonly />
</label>
</span></td>
</tr>
<tr>
<td valign="top"><span class="style1">วันที่สั่งซื้อ</span></td>
<td><span class="style1">
<label>
<input name="textfield2" type="text" id="textfield2" value="<?=strtodateThai(date("d-m-Y"));?>" />
</label>
</span></td>
</tr>
<tr>
<td> </td>
<td><span class="style1">
<label></label>
</span></td>
</tr>
</table>
<table width="616" border="0">
<tr>
<td width="117">รหัสผู้จำหน่าย</td>
<td width="489">THI01</td>
</tr>
<tr>
<td>ชื่อผู้จำหน่าย</td>
<td>บ.ทีมไทยพลาสติกอินดัสทรี จำกัด</td>
</tr>
<tr>
<td>ที่อยู่</td>
<td>126/1ซอยประชาอุทิศ76 แขวงทุ่งครุ เขตทุ่งครุ กรุงเทพฯ</td>
</tr>
<tr>
<td>โทร</td>
<td>024267175</td>
</tr>
</table>
<p>
<?php
$sql = "
SELECT A.Mat_ID,
A.Mat_Name,
B.Mat_Price
From material As A,
purchaseprice As B
WHERE A.Mat_ID = B.Mat_ID And
A.Mat_ID = '" . $_REQUEST['Mat_ID'] . "'
";
$result = mysql_query($sql);
$material = array();
$i = 0;
while($row = mysql_fetch_array($result)) {
$material[] = '
<tr id="materialrow' . $row['Mat_ID'] . '" >
<td align="center" ><a alt="ลบรายการนี้" title="ลบรายการนี้" href="javascript:delMaterial(\'' . $row['Mat_ID'] . '\')" ><img src="images/111.gif" alt="ลบ"/></a></td>
<td align="center" >' . ++$i . '<input type="hidden" name="Mat_ID[' . $row['Mat_ID'] . ']" id="Mat_ID' . $row['Mat_ID'] . '" value="' . $row['Mat_ID'] . '" /></td>
<td>' . $row['Mat_Name'] . '</td>
<td align="right" >'.$row['Mat_Price']. '<input type="hidden" name="Mat_Price" Mat_ID="' . $row['Mat_ID'] . '" value="' . $row['Mat_Price'] . '" /><input type="hidden" name="materialprice[' . $row['Mat_ID'] . ']" id="materialprice[' . $row['Mat_ID'] . ']" value="' . $row['Mat_Price'] . '" /></td>
<td align="center" ><input type="text" class="required" size="5" style="text-align: center;" id="numofmaterial[' . $row['Mat_ID'] . ']" name="numofmaterial[' . $row['Mat_ID'] . ']" onblur="processprice(this.value, ' . $row['Mat_Price'] . ', \'' . $row['Mat_ID'] . '\');" value="' . $row['Qty']*1 . '"/></td>
<td align="right" ><span id="summaterial' . $row['Mat_ID'] . '" >' . getCurrency($row['Amount']) . '</span></td>
</tr>
';
$Total += $row['Amount'];
}
?>
<br/ >
</p>
<fieldset>
<legend> <span class="style1"><strong>ข้อมูลวัตถุดิบ</strong></span> </legend>
<table border="0" cellspacing="0" cellpadding="2" width="100%" class="tablelistdata" id="tablematerial" name="tablematerial">
<tr>
<th width="20"> </th>
<th width="110" ><span class="style1">ลำดับ</span></th>
<th width="499"><span class="style1">ชื่อวัตถุดิบ</span></th>
<th width="119" ><span class="style1">ราคา/หน่วย</span></th>
<th width="110" ><span class="style1">จำนวน</span></th>
<th width="92" ><span class="style1">รวม</span></th>
</tr>
<?php if (count($material)) : ?>
<?php echo implode("", $material); ?>
<?php else : ?>
<tr>
<td colspan="6" > </td>
</tr>
<?php endif; ?>
<tr>
<td colspan="5" align="center" >รวม</td>
<td align="right" ><span id="sumprice" ><?php echo getCurrency($Total); ?></span></td>
</tr>
</table>
<input type="button" name="addmaterial" id="addmaterial" value="เพิ่มรายการวัตถุดิบ" onClick="openMeterialSearch();" />
</fieldset>
<input type="submit" id="submit" name="submit" value="บันทึกข้อมูลการสั่งซื้อวัตถุดิบ" />
<?php
// ตรวจรับค่าจากตัวแปร acton จากลิ้งค์
// ----------- ถ้าเพิ่มข้อมูล action = insert
if ($_GET['action']=='')
{
echo'<input name="action" type="hidden" value="insert">';
}
?>
</form>
<?
echo $sql1;
?>
<p> </p>
</fieldset>
<p> </p>
<p> </p>
<p align="center"> </p>
</body>
</form>
มันฟ้องว่าแบบนี้อ่ะครับ
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\AppServ\www\furniture\purchaseorder.php on line 62Tag : PHP, MySQL
Date :
2011-04-30 19:48:07
By :
mangrungrang
View :
748
Reply :
5
line 62 มันอยู่ตรงไหนของโลกครับ บอกด้วยครับ
Date :
2011-04-30 21:40:27
By :
PlaKriM
insert into purchaseorder ('Purorder_ID','Pur_Date') Values ($_POST['textfield'],$_POST['textfield2'])";
Date :
2011-04-30 22:51:54
By :
mangrungrang
echo $sql_insert_1 = "
insert into purchaseorder ('Purorder_ID','Pur_Date') Values ($_POST['textfield'],$_POST['textfield2'])"
ผิดตรงนี้ครับ
Date :
2011-04-30 23:01:24
By :
webmaster
งงจริงๆครับ
แก้ไงก็แก้ไม่ได้
Date :
2011-05-01 01:06:11
By :
mangrungrang
Load balance : Server 02