 |
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRI |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
$sql = "select * from product_type";
$ex = mysql_query($sql, $conn);
echo "<ul>";
while ($rs=mysql_fetch_assoc($ex)){
echo "<li><a href='product_list.php?id=$rs[type_id]' >$rs[type_name]</a></li>";
}
echo "</ul>"
?>
|
ประวัติการแก้ไข 2015-04-28 19:21:17 2015-04-28 19:21:42
 |
 |
 |
 |
Date :
2015-04-28 19:19:55 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หาย error แล้วค่ะ ขอบคุณพี่มากๆนะคะ

|
 |
 |
 |
 |
Date :
2015-04-28 23:30:46 |
By :
nuttiporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จริง session_register ไม่ต้อง ใช้ก็ได้ นะ error มันบอกไม่รู้จัก session_register
|
 |
 |
 |
 |
Date :
2015-04-29 14:59:11 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
และต้องแก้โค้ดยังไงบ้างคะ รบกวนด้วยค่ะ ขอบคุณนะคะ
|
 |
 |
 |
 |
Date :
2015-04-29 15:19:10 |
By :
nuttiporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลบออกไปเลบ ครับ
session_register("sess_id");
session_register("sess_name");
session_register("sess_price");
session_register("sess_num");
ใช้
$_SESSION["sess_id"] =XXXX
$_SESSION["sess_name"] = XXX
$_SESSION["sess_price"];
$_SESSION["sess_num"];
|
ประวัติการแก้ไข 2015-04-29 15:21:34 2015-04-29 15:25:41
 |
 |
 |
 |
Date :
2015-04-29 15:20:46 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เวลาใช้ ให้ใช้งาน เหมือน array เลยครับ
Code (PHP)
session_sart();
$_SESSION['id']=123;
if( $_SESSION['id']==123){ do_it(); }
unset($_SESSION['id']);
|
 |
 |
 |
 |
Date :
2015-04-29 15:22:28 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หาย error แล้วนะคะ แต่มา error หน้าที่จะใส่ตะกร้ามันขึ้นแบบนี้น่ะค่ะ
Notice: Undefined variable: sess_id in D:\xampp\htdocs\nut\basket.php on line 29
ยังไม่มีสินค้าอยู่ในตะกร้า
โค้ด basket.php
Code (PHP)
<?php
session_start();
?>
<html>
<head>
<title> ระบบร้านค้าออนไลน์ </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body topmargin="0" leftmargin="0">
<table width="850" border="0" cellpadding="10">
<tr>
<td width="250"><h1>ร้านค้าออนไลน์ </h1>
<p>[ <a href="index.php">หน้าแรก</a> ]
[ <a href="basket.php">ดูตะกร้า</a> ]</p></td>
<td width="550"> </td>
</tr>
<tr>
<td valign="top">ประเภทสินค้า
<?php
include "connect.php";
include "type_menu.php";
?>
</td>
<td width="550" align="center" valign="middle">
<?php
if (count($sess_id) == 0) {
print "ยังไม่มีสินค้าอยู่ในตะกร้า <br>";
} else {
?>
<form action="basket_cal.php" method="post">
<table width="550" border="1">
<tr>
<th bgcolor="#CCCCCC">ลบ</th>
<th bgcolor="#CCCCCC">ชื่อสินค้า</th>
<th bgcolor="#CCCCCC">จำนวน</th>
<th bgcolor="#CCCCCC">ราคา</th>
<th bgcolor="#CCCCCC">รวม</th>
</tr>
<?php
for ($i = 0; $i<count($sess_id); $i++) {
$total_unit = $sess_num[$i] * $sess_price[$i] ;
$total = $total + $total_unit;
echo "
<tr>
<td align=center><input type=checkbox name=id_del[] value=$sess_id[$i]></td>
<td>$sess_name[$i]</td>
<td align=center><input type=text name=id_add[] value=$sess_num[$i] size=4></td>
<td align=center>$sess_price[$i]</td>
<td align=center>$total_unit</td>
</tr> ";
}
?>
</table>
<p align="right">
<?php
echo "จำนวนเงินทั้งหมด $total บาท" ;
?>
<br><br>
<input type="submit" name="calculate" value="คำนวณใหม่">
<input type="submit" name="complete" value="สั่งซื้อสินค้า">
</p>
</form>
<?php
}
?>
</td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2015-04-29 17:07:16 |
By :
nuttiporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูวิธีเซท จาก คห 7 ครับ
เนื่องจากคำสั่ง session_register() ได้ถูกยกเลิกไปแล้ว
การใช้ $sess_id จึงไม่สามารถใช้ได้ ต้องอ้างอิงเต็มรูปแบบ ครับ
$_SESSION['sess_id'];
$_SESSION['sess_num'][$i]
|
 |
 |
 |
 |
Date :
2015-04-29 17:13:53 |
By :
มั่วๆไป |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หนูทำระบบตะกร้าสินค้า ตามหนังสือ PHPWorkshop เล่ม 2 ที่มีแจกโค้ดไว้ในเว็บ หนูลองพยายามอ่านโค้ดแล้ว แต่หนูก็ไม่เข้าใจ เลยแนบโค้ดมาให้ ช่วยหน่อยนะคะ ทำไมมันถึง error แบบนั้น

โค้ด basket.php
Code (PHP)
<?php
@session_start();
?>
<html>
<head>
<title> ระบบร้านค้าออนไลน์ </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body topmargin="0" leftmargin="0">
<table width="850" border="0" cellpadding="10">
<tr>
<td width="250"><h1>ร้านค้าออนไลน์ </h1>
<p>[ <a href="index.php">หน้าแรก</a> ]
[ <a href="basket.php">ดูตะกร้า</a> ]</p></td>
<td width="550"> </td>
</tr>
<tr>
<td valign="top">ประเภทสินค้า
<?php
include "connect.php";
include "type_menu.php";
?>
</td>
<td width="550" align="center" valign="middle">
<?php
if (count($_SESSION['sess_id'])== 0) {
print "ยังไม่มีสินค้าอยู่ในตะกร้า <br>";
} else {
?>
<form action="basket_cal.php" method="post">
<table width="550" border="1">
<tr>
<th bgcolor="#CCCCCC">ลบ</th>
<th bgcolor="#CCCCCC">ชื่อสินค้า</th>
<th bgcolor="#CCCCCC">จำนวน</th>
<th bgcolor="#CCCCCC">ราคา</th>
<th bgcolor="#CCCCCC">รวม</th>
</tr>
<?php
for ($i = 0; $i<count($_SESSION['sess_id']); $i++) {
$total_unit = $_SESSION['sess_num'][$i] *
$_SESSION['sess_price'][$i] ;
$total = $total + $total_unit;
echo "
<tr>
<td align=center><input type=checkbox name=id_del[] value=sess_id[$i]></td>
<td>sess_name[$i]</td>
<td align=center><input type=text name=id_add[] value=sess_num[$i] size=4></td>
<td align=center>sess_price[$i]</td>
<td align=center>$total_unit</td>
</tr> ";
}
?>
</table>
<p align="right">
<?php
echo "จำนวนเงินทั้งหมด $total บาท" ;
?>
<br><br>
<input type="submit" name="calculate" value="คำนวณใหม่">
<input type="submit" name="complete" value="สั่งซื้อสินค้า">
</p>
</form>
<?php
}
?>
</td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2015-04-29 23:10:38 |
By :
nuttiporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code ที่เอามาถามมันเก่า คุณน้องใช้ xampp มันก็จะ Error แบบนี้ล่ะ
ถ้าไม่ปรับ Code ก็ .... หาวิธีปิด Error ทั้งหมด
ไม่งั้นจะทำแค่โปรเจ็คส่ง จำลอง Server ใหม่ใช้ Appserv2.5.10 พอล่ะ
มันจะได้ไม่ Error
|
 |
 |
 |
 |
Date :
2015-04-30 05:16:58 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2015-04-30 07:31:46 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จขกทใช้ xampp ก็ดีอยู่แล้ว ไปแก้โค้ดให้ถูกต้องดีกว่า
อย่าแนะนำให้ใครใช้ Appserv อีกเลย ปล่อยมันตายไปเถอะ
แต่ก็คิดว่าคงตายยาก เพราะขนาดอาจารบางมหาลัยยังเอา Appserv มาสอนเด็กอยู่เลย
|
 |
 |
 |
 |
Date :
2015-04-30 09:49:14 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หนูจะลองปรับดูนะคะ ขอบคุณพี่ๆทุกคนมากๆค่ะ 
|
 |
 |
 |
 |
Date :
2015-04-30 12:46:37 |
By :
nuttiporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เจอปัญหาเดียวกันเลยครับ อยากได้คำแนะนำว่าต้องแก้ตรงไหน

|
 |
 |
 |
 |
Date :
2022-04-16 15:39:21 |
By :
MajTanya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|