|
|
|
รบกวนดู Code ให้ทีครับ Parse error: syntax error, unexpected $end in 'C:\AppServ\www\database\cart_ss.php' |
|
|
|
|
|
|
|
Parse error: syntax error, unexpected $end in C:\AppServ\www\database\cart_ss.php on line 125
code
<?php
session_start();
$dblink = mysql_connect("localhost","root","1234");
mysql_query("USE shopping_cart;");
$sid = session_id();
$pid = "";
if(isset($_POST['pid'])) {
$pid = $_POST['pid'];
}
$act = "";
if(isset($_POST['act'])) {
$act = $_POST['act'];
}
$sql = "";
if($act=="add") {
$q = $_POST['q'];
$sql = <<<SQL
SELECT product_name, price FROM product
WHERE pid = $pid;
SQL;
$result = mysql_query($sql);
$pname = mysql_result($result,0,0);
$price = mysql_result($result,0,1);
$sql = <<<SQL
REPLACE INTO cart VALUES
('$sid', $pid, '$pname', $price, $q, NOW());
SQL;
}
else if ($act=="del") {
$sql = <<<SQL
DELETE FROM cart
WHERE pid = $pid;
SQL;
}
else if($act=="clear") {
$sql = <<<SQL
DELETE FROM cart
WHERE sid = '$sid';
SQL;
}
mysql_query($sql);
$sql = <<<SQL
SELECT * FROM cart
WHERE sid = '$sid';
SQL;
$result = mysql_query($sql);
header("content-type:text/plain; charset=tis-620");
if(mysql_num_rows($result)==0) {
echo "ไม่มีสินค้าในรถเข็น";
mysql_close($dblink);
exit();
}
$tb = <<<TABLE
<table width="98%" border="1" bordercolor="gray"
style="border-collapse:collapse;">
<caption>รายการสินค้าในรถเข็น</caption>
<tr align="right" bgcolor="powderblue">
<th align="center">สินค้า</th><th>ราคา</th>
<th>#</th><th>รวม</th>
</tr>
TABLE;
$grand_total = 0;
while($cart=mysql_fetch_array($result))
{
$sub_total=$cart['price']*$cart['quantity'];
$tbody = <<<TBODY
<tr align="right" valign="top">
<td align="left">
<div style="float:left;">
<button onclick="deCart({$cart['pid']})"
class="bt_cart">ลบ</button>
</div>
{$cart['product_name']}
</td>
<td>{$cart['price']}</td>
<td>{$cart['quantity']}</td>
<td>$sub_total</td>
</tr>
$tb .= $tbody;
$grand_total += $sub_total;
}
$tb .= "<tr><td align=center>รวมทั้งหมด</td>";
$tb .= "<td align=right colspan=3>$grand_total</td></tr>";
$tb .= "</table>";
TBODY;
$bt = <<<BT
<p align="center">
<button onclick="clearCart()">ลบทั้งหมด</button>
<button onclick="location='customer_info.html'">สั่งซื้อ »
</button>
</p>
BT;
echo $tb . $bt;
mysql_close($dblink);
?>
รบกวนหลายอันหน่อยนะครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\database\customer_list.php on line 41
CODE
<html>
<head>
<script src="ajax_framework.js"> </script>
<script>
function viewCustomer (cid) {
open ('view_order.php?cid=' + cid);
}
fucntion deleteCustomer(cid) {
if(!confirm('ลบรายการนี้?')) {
return;
}
var data = "cid=" + cid;
var URL = "delete_customer.php";
ajaxLoad('post', URL, data, 'msg');
}
</script>
</head>
<body>
<?php
$dblink = mysql_connect("localhost", "root", "1234");
mysql_query("USE shopping_cart;");
$sql = <<<SQL
SELECT *, DATE_FORMAT(order_dat,'%d-%m-%y') AS dt
FROM customer;
SQL;
$result = mysql_query($sql);
?>
<p>
<table width="600" border="1" cellpadding="3" style="border-collapse:collapse;">
<tr bgcolor="#eeeeff">
<th width="50">ลำดับ</th><th width="250">ชื่อลูกค้า</th>
<th width="100">วันที่สั่งซื้อ</th><th>ดำเนินการ</th></tr>
<?php
$i = 0;
while($cust = mysql_fetch_array($result)) {
$i++;
echo <<<TBODY
<tr id="row_{$cust['custid']}" align="center" valign="top">
<td>$i</td>
<td align="left">{$cust['name']}</td><td>{$cust['dt']}</td>
<td>
<button onclick="viewCustomer({$cust['custid']})">
รายละเอียด</button>
<button onclick="viewCustomer({$cust['custid']})">
ลบ</button>
</td>
</tr>
TBODY;
}
echo "</table>";
mysql_close($dblink);
?>
</body>
</html>
ทำมาหลายวันแล้วไม่ผาานสักที
Tag : - - - -
|
|
|
|
|
|
Date :
2010-02-10 14:09:00 |
By :
baronknight |
View :
1230 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parse error: syntax error, unexpected $end in C:\AppServ\www\database\cart_ss.php on line 125
ตรวจสอบ () [] {} ว่าครบหรือป่าวครับ
ตาลายไปหมดแล้ว
สู่ๆครับ
|
|
|
|
|
Date :
2010-02-10 17:01:58 |
By :
viruscom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = <<<SQL
$tb = <<<TABLE
echo <<<TBODY
$bt = <<<BT
|
|
|
|
|
Date :
2010-02-10 17:08:57 |
By :
ความรู้เท่าหางอึ่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|