 |
ว่าด้วยเรื่อง $sql = "SELECT * FROM จร้าาาาาาาาาาา You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the |
|
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2011-06-05 15:07:33 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำมาห้าวันแล้วยังไม่คืบหน้าเลย บทความที่ให้มาลองอ่านแล้วก็ยังแก้ไม่ได้ YY ช่วยทีคับ
output
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
Code (PHP)
<?
session_start();
include("../lib/utility.php");
connect_db();
// Prepare Variables
$txtshipping = $_REQUEST["txtshipping"];
$txtorder = $_REQUEST["txtorder"];
$cart = $_SESSION["cart"];
$username = $_SESSION["username"];
$email = $_SESSION["email"];
$email = $_REQUEST["email"];
$id = $_REQUEST["id"];
// Check Input
$error = "";
if ($txtshipping == "") {
$error .= "กรุณากรอกให้เสร็จ<br />";
}
else if ($txtorder == "") {
$error .= "กรุณากรอกให้เสร็จ<br />";
}
// Action
if ($error == "") {
// Member
$sql = "SELECT * FROM member"
. " WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$member_id = $row["id"];
// Order
$sql = "INSERT INTO `order`"
. " (shipping, date, member_id,order_detail )"
. " VALUES('$txtshipping', NOW(), $member_id,'$txtorder')";
mysql_query($sql) or die(mysql_error());
$order_id = mysql_insert_id();
// Order Detail
foreach ($cart as $product_id => $item) {
$sql = "INSERT INTO order_detail"
. " (amount, product_id, order_id,detail_name)"
. " VALUES($item[amount], $product_id, $order_id,'$item[name]')";
mysql_query($sql) or die(mysql_error());
}
// Cart
unset($_SESSION["cart"]);
}
// Show Result
if ($error == "") {
$result = " ระบบยืนยันการสั่งซื้อเรียบร้อยระบบจะส่ง E-mail เพื่อยืนยันการสั่งซื้อภายใน20นาที ขอขอบพระคุณที่ใช้บริการ<br />"
. "<a href='index.php'>สั่งซื้อใหม่</a>";
}
else {
$result = $error
. "<a href='#' onclick='history.back(); return false;'>กลับไป</a>";
}
?>
<?
$sql = "SELECT * FROM `order`"
. " INNER JOIN member ON `order`.member_id = member.id"
. " WHERE `order`.id=$id";
$result3 = mysql_query($sql) or die(mysql_error());
$row3 = mysql_fetch_array($result3);
$sql = "SELECT *, order_detail.id as id FROM order_detail"
. " INNER JOIN product ON order_detail.product_id = product.id"
. " WHERE order_detail.order_id=$id"
. " ORDER BY order_detail.id";
$result4 = mysql_query($sql) or die(mysql_error());
?>
<?
$strTo = $row['email'] ;
$strSubject = "ใบสั่งสินค้า";
$strHeader = "Content-type: text/html; charset=utf-8"; // or UTF-8 //
$strHeader = "From: [email protected]";
$strMessage = "
--------------------------
ใบสั่งงานds.net
--------------------------
วันเวลาที่สั่งซื้อ '$row3[date]'
user: '$row[username]'
ชื่อ-สกุล: '$row[name]' '$row[surname]'
ที่อยู่: '$row[address]'
email: '$row[email]'
รายการที่ท่านสั่ง '$row3[detail_name]'
ข้อมูลการโอนจ่ายของท่าน:'$row[shipping]'
ข้อมูลความต้องการของท่าน:'$row3[order_detail]'
_________________________
";
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Email Sending.ระบบกำลังส่งขอมูลไปยังบัญชีของคุณภายใน20นาที ขอบคุณที่ใช้บริการ ";
}
else
{
echo "Email Can Not Send. กรุณาตรวจสอบบัญชีและรายการ";
}
?>
<!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>ระบบตะกร้าสินค้า - ยืนยันการสั่งซื้อ</title>
</head>
<meta http-equiv='refresh' content='2;URL=../index.php' />;
<body>
<?=$result?>
</body>
</html>
จุดที่น่าสงสัยที่สุดคือ
Code (PHP)
<?
$sql = "SELECT * FROM `order`"
. " INNER JOIN member ON `order`.member_id = member.id"
. " WHERE `order`.id=$id";
$result3 = mysql_query($sql) or die(mysql_error());
$row3 = mysql_fetch_array($result3);
$sql = "SELECT *, order_detail.id as id FROM order_detail"
. " INNER JOIN product ON order_detail.product_id = product.id"
. " WHERE order_detail.order_id=$id"
. " ORDER BY order_detail.id";
$result4 = mysql_query($sql) or die(mysql_error());
?>
|
ประวัติการแก้ไข 2011-06-06 16:45:41 2011-06-10 18:49:54 2011-06-10 18:52:08
 |
 |
 |
 |
Date :
2011-06-06 16:44:30 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำมาห้าวันแล้วยังไม่คืบหน้าเลย บทความที่ให้มาลองอ่านแล้วก็ยังแก้ไม่ได้ YY ช่วยทีคับ
output
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
Code (PHP)
<?
session_start();
include("../lib/utility.php");
connect_db();
// Prepare Variables
$txtshipping = $_REQUEST["txtshipping"];
$txtorder = $_REQUEST["txtorder"];
$cart = $_SESSION["cart"];
$username = $_SESSION["username"];
$email = $_SESSION["email"];
$email = $_REQUEST["email"];
$id = $_REQUEST["id"];
// Check Input
$error = "";
if ($txtshipping == "") {
$error .= "กรุณากรอกให้เสร็จ<br />";
}
else if ($txtorder == "") {
$error .= "กรุณากรอกให้เสร็จ<br />";
}
// Action
if ($error == "") {
// Member
$sql = "SELECT * FROM member"
. " WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$member_id = $row["id"];
// Order
$sql = "INSERT INTO `order`"
. " (shipping, date, member_id,order_detail )"
. " VALUES('$txtshipping', NOW(), $member_id,'$txtorder')";
mysql_query($sql) or die(mysql_error());
$order_id = mysql_insert_id();
// Order Detail
foreach ($cart as $product_id => $item) {
$sql = "INSERT INTO order_detail"
. " (amount, product_id, order_id,detail_name)"
. " VALUES($item[amount], $product_id, $order_id,'$item[name]')";
mysql_query($sql) or die(mysql_error());
}
// Cart
unset($_SESSION["cart"]);
}
// Show Result
if ($error == "") {
$result = " ระบบยืนยันการสั่งซื้อเรียบร้อยระบบจะส่ง E-mail เพื่อยืนยันการสั่งซื้อภายใน20นาที ขอขอบพระคุณที่ใช้บริการ<br />"
. "<a href='index.php'>สั่งซื้อใหม่</a>";
}
else {
$result = $error
. "<a href='#' onclick='history.back(); return false;'>กลับไป</a>";
}
?>
<?
$sql = "SELECT * FROM `order`"
. " INNER JOIN member ON `order`.member_id = member.id"
. " WHERE `order`.id=$id";
$result3 = mysql_query($sql) or die(mysql_error());
$row3 = mysql_fetch_array($result3);
$sql = "SELECT *, order_detail.id as id FROM order_detail"
. " INNER JOIN product ON order_detail.product_id = product.id"
. " WHERE order_detail.order_id=$id"
. " ORDER BY order_detail.id";
$result4 = mysql_query($sql) or die(mysql_error());
?>
<?
$strTo = $row['email'] ;
$strSubject = "ใบสั่งสินค้า Designwebpark.net";
$strHeader = "Content-type: text/html; charset=utf-8"; // or UTF-8 //
$strHeader = "From: [email protected]";
$strMessage = "
--------------------------
ใบสั่งงาน Designwebpark.net
--------------------------
วันเวลาที่สั่งซื้อ '$row3[date]'
user: '$row[username]'
ชื่อ-สกุล: '$row[name]' '$row[surname]'
ที่อยู่: '$row[address]'
email: '$row[email]'
รายการที่ท่านสั่ง '$row3[detail_name]'
ข้อมูลการโอนจ่ายของท่าน:'$row[shipping]'
ข้อมูลความต้องการของท่าน:'$row3[order_detail]'
_________________________
";
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Email Sending.ระบบกำลังส่งขอมูลไปยังบัญชีของคุณภายใน20นาที ขอบคุณที่ใช้บริการ ";
}
else
{
echo "Email Can Not Send. กรุณาตรวจสอบบัญชีและรายการ";
}
?>
<!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>ระบบตะกร้าสินค้า - ยืนยันการสั่งซื้อ</title>
</head>
<meta http-equiv='refresh' content='2;URL=../index.php' />;
<body>
<?=$result?>
</body>
</html>
จุดที่น่าสงสัยที่สุดคือ
Code (PHP)
<?
$sql = "SELECT * FROM `order`"
. " INNER JOIN member ON `order`.member_id = member.id"
. " WHERE `order`.id=$id";
$result3 = mysql_query($sql) or die(mysql_error());
$row3 = mysql_fetch_array($result3);
$sql = "SELECT *, order_detail.id as id FROM order_detail"
. " INNER JOIN product ON order_detail.product_id = product.id"
. " WHERE order_detail.order_id=$id"
. " ORDER BY order_detail.id";
$result4 = mysql_query($sql) or die(mysql_error());
?>
-ขอบคุณจากใจครับ
|
 |
 |
 |
 |
Date :
2011-06-10 18:48:51 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ม้น error บรรทัดไหนไม่มีบอกหรอครับ
|
 |
 |
 |
 |
Date :
2011-06-10 22:12:47 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
$sql = "SELECT * FROM `order`"
. " INNER JOIN member ON `order`.member_id = member.id"
. " WHERE `order`.id=$id";
$result3 = mysql_query($sql) or die(mysql_error());
$row3 = mysql_fetch_array($result3);
$sql = "SELECT *, order_detail.id as id FROM order_detail"
. " INNER JOIN product ON order_detail.product_id = product.id"
. " WHERE order_detail.order_id=$id"
. " ORDER BY order_detail.id";
$result4 = mysql_query($sql) or die(mysql_error());
?>
>> where order_detail.order_id='$id' แบบนี้ครับ
|
 |
 |
 |
 |
Date :
2011-06-11 14:43:51 |
By :
nut_ch31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ข้อมูลเพิ่ม เติมคับ ไฟล์นี้ เปนไฟล์กรออกข้อมูลก่อนหน้า ไฟลล์ที่ถามไปครับ จะเปนลิสบ๊อก รับพารามิเตอร์ส่งไปยังไฟล์ที่สงสัยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Code (PHP)
<?
session_start();
include("../lib/utility.php");
if (!isset($_SESSION["username"])) {
header("location:../member/login_form.php");
return;
}
connect_db();
$username = $_SESSION["username"];
$cart = $_SESSION["cart"];
// Action - Get Data
$sql = "SELECT * FROM member WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$cart = $_SESSION["cart"];
?>
<!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"><style type="text/css">
<!--
body {
background-color:#FFF;
}
h1 {
text-shadow: 0 1px 0 #ccc,
0 2px 0 #c9c9c9,
0 3px 0 #bbb,
0 4px 0 #b9b9b9,
0 5px 0 #aaa,
0 6px 1px rgba(0,0,0,.1),
0 0 5px rgba(0,0,0,.1),
0 1px 3px rgba(0,0,0,.3),
0 3px 5px rgba(0,0,0,.2),
0 5px 10px rgba(0,0,0,.25),
0 10px 10px rgba(0,0,0,.2),
0 20px 20px rgba(0,0,0,.15);
}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- <link href="../member/login-box.css" rel="stylesheet" type="text/css">--->
<title>ระบบตะกร้าสินค้า - ระบุสถานที่จัดส่ง</title>
</head>
<body>
<div align="center">
<h1>ใบสั่งงาน</h1>
</div>
<form method="post" action="confirm_order.php">
<table width="280%" border="0" align="center" cellpadding="5" cellspacing="1" id="login-box-field">
<tr>
<td align="center"><table width="654" height="478" border="0" class="login-box-options" id="login-box">
<tr>
<th height="62" align="left" class="form-login" scope="col">ผู้สั่งทำ</th>
<th align="left" class="form-login" scope="col"><ul class="toneblack">
<table width="200" border="0">
<tr>
<th scope="col"><?php echo $row['name'] ; ?></th>
<th scope="col"><?php echo $row['surname'] ; ?></th>
</tr>
</table>
</ul></th>
<th class="form-login" scope="col"><table width="200" border="0">
<tr>
<th scope="col"><b><font color="red"><? echo date("H:i:s"); ?></font></b></th>
</tr>
<tr>
<td align="center"><b><font color="red"><? echo date("d/m/Y");; ?></font></b></td>
</tr>
</table></th>
</tr>
<tr>
<td class="form-login">user</td>
<td class="form-login"><?php echo $row['username'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">email</td>
<td class="form-login"><?php echo $row['email'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">เพศ</td>
<td class="form-login"><?php echo $row['gender'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr class="form-login">
<td class="form-login">ที่อยู่</td>
<td class="form-login"><?php echo $row['address'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">ประเทศ</td>
<td class="form-login"><?php echo $row['country'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">วันเกิด</td>
<td class="form-login"><?php echo $row['birthday'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">เปิดบัญชีเมื่อ</td>
<td class="form-login"><?php echo $row['create'] ; ?></td>
<td class="form-login"> </td>
</tr>
<tr>
<td colspan="2" class="form-login"><table width="1044" border="0">
<tr>
<th width="223" align="left" scope="row">คุณได้สั่งซื้อ</th>
<td width="811"> <? if (sizeof($cart) > 0) { ?>
<form action="update_cart.php" method="post">
<table width="80%" align="center" cellpadding="5" cellspacing="1">
<tr>
<th width="40"> </th>
<th width="80"> </th>
<th> </th>
<th width="80"> </th>
<th width="80"> </th>
<th width="80"> </th>
</tr>
<? $i = 0;
$sum = 0;
foreach ($cart as $id => $item) {
?>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td><?=$item["name"]?></td>
<td align="right"><?=number_format($item["price"])?></td>
<td align="center">
<input name="amount[<?=$id?>]" type="text" style="text-align: right" value="<?=$item["amount"]?>" size="2" readonly="readonly" />
</td>
<td align="right"><?=number_format($item["price"]*$item["amount"])?></td>
</tr>
<? $sum += $item["price"]*$item["amount"];
$i++;
}
?>
<tr>
<td colspan="5" align="right">ราคารวมทั้งหมด</td>
<td align="right"><?=number_format($sum)?></td>
</tr>
<tr>
<td align="center" colspan="6"> </td>
</tr>
</table>
</form>
<? } else { ?>
<div align="center">
<b>ไม่มีสินค้าในตะกร้า</b><br />
<a href="index.php">กลับไปที่ผลการค้นหา</a>
</div>
<? } ?>
</td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
</table></td>
<td class="form-login"> </td>
</tr>
<tr>
<td class="form-login">รายระเอียดการสั่งซื้อ(ตัวอย่าง)</td>
<td class="form-login"> </td>
<td class="form-login"> </td>
</tr>
<tr>
<td colspan="3" class="form-login"><h5>
<textarea name="address2" cols="150" rows="8" readonly="readonly">ชื่อบัญชีธนาคาร
นาย สะอาด สีสะอาด
เลขบัญชี 005-111-222-44444
ธนาคาร กรุงธนบุรี
สาขา นครหลวง
คาดว่าจะโอนเมื่อเวลา 12.00
เป็นเงิน 500.75
</textarea>
</h5></td>
</tr>
<tr>
<td colspan="3" class="form-login">รายระเอียดการสั่งซื้อ</td>
</tr>
<tr>
<td colspan="2" class="form-login"><textarea name="txtshipping" cols="150" rows="10" id="txtshipping"></textarea></td>
<td class="form-login"> </td>
</tr>
<tr >
<td class="form-login">รายระเอียดการสั่งทำ(ตัวอย่าง)</td>
<td class="form-login"> </td>
<td class="form-login"> </td>
</tr>
<tr>
<td colspan="3" class="form-login"><textarea name="address4" cols="150" rows="8" readonly="readonly" id="address4">pink package รหัส 00050
ราคา 500
โดเมนเนมที่อยากได้ www.mmm.net
โทนสีที่อยากได้ คือสีฟ้า ขาว
สไตล์ เรียบง่าย แบบราชการ
</textarea></td>
</tr>
<tr>
<td colspan="3" class="form-login"><? if (sizeof($cart) > 0) { ?>
<? } else { ?>
<? } ?>
</td>
</tr>
<tr>
<td colspan="3" class="form-login"></p>
รายระเอียดการสั่งทำ</td>
</tr>
<tr>
<td colspan="3" class="form-login"><textarea name="txtorder" cols="150" rows="8" id="txtorder"></textarea></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><table width="260" border="0" class="form-login" id="table">
<tr>
<th width="107" scope="col"><input type="submit" value="ส่ง" /></th>
<th width="83" scope="col"><input type="reset" value="เคลียร์" /></th>
</tr>
</table></td>
</tr>
</table>
<span class="form-login"></span>
<p class="tonewhite" id="table_white"> </p>
</form>
<p></body>
</html>
|
ประวัติการแก้ไข 2011-06-11 21:06:01
 |
 |
 |
 |
Date :
2011-06-11 20:43:26 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Console.Writeline("Hello world");
|
 |
 |
 |
 |
Date :
2011-06-13 14:48:53 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|