我正在尝试建立一个购物车,但出现此错误
解析错误:语法错误,意外的')',在第12行的C:\ xampp \ htdocs \ products.php中预期为'('
这是代码
<?php
if(isset($_GET['action']) && $_GET['action']==add){
$id=intval($_GET['id']);
if(isset($_SESSION['cart'])){
$_SESSION['cart'][$id]['quantity']++;
} else {
$sql_s="SELECT * FROM tutorial WHERE id_product=[$id]";
$query_s=mysql_query($sql_s);
if (mysql_num_rows(&query_s)!=0){
} else {
$message="This ID is invalid!";
}
}
?>
<?php
if(isset($message)){
echo"<h2>$message</h2>";
}
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Action</th>
</tr>
<?php
$sql="SELECT * FROM tutorial ORDER BY name ASC";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)) {
?>
<tr>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['description'] ?></td>
<td>€<?php echo $row['price'] ?></td>
<td><a href="index.php?page=products$action=add&id=<?php echo $row['id_product']?>">Add to cart</a></td>
</tr>
<?php
}
?>
</table>
谁能帮助我,将不胜感激!
您有一个无效的字符,该字符使分析器无法正常运行。
if (mysql_num_rows(&query_s)!=0){
应该
if (mysql_num_rows($query_s)!=0){
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句