0

当我尝试将商品添加到购物车时,我收到“解析错误:语法错误,C:\Program Files\Abyss Web Server\htdocs\added.php 中出现意外 '>'”

我查看了代码以查看脚本中可能存在先前错误但找不到任何错误。上面的消息将我指向其他页面链接的第一行,这在脚本末尾附近

echo '<p><a href="shop.php">Shop</a> |

但是,我找不到错误,我认为它一定在其他地方。我像往常一样尝试了一个 PHP 在线检查器,但什么也没找到。

这是完整的脚本。

<?php

session_start() ;

if ( !isset( $_SESSION[ 'user_id' ]))
{
 require ( 'login_tools.php' ) ;
 load() ;
}

$page_title = 'Cart Addition' ;
include ( 'includes/header.html' );

if ( isset( $_GET['ID'])) $id = $_GET['id'] ;

require ( '..connect_db.php' ) ;

$q = "SELECT * FROM shop WHERE item_id = $id " ;
$r = mysqli_query( $dbc , $q ) ;
if ( mysqli_num_rows( $r ) == 1 )
{ 
 $row = mysqli_fetch_array( $r , MYSQLI_ASSOC ) ;


if ( isset( $_SESSION['CART'][$id]))
{
 $_SESSION['cart'][$id]['quantity']++ ;
 echo '<p>Another '.$row["item_name"].
       'has been added to your cart</p>';
}
else
{
 $_SESSION['cart'][$id]=
 array ( 'quantity' => 1, 'price' => $row['item_price']) ;
 echo '<p>A '.$row["item_name"].
       'has been added to your cart</p>. ;
}
}

mysqli_close( $dbc ) ;

echo '<p><a href="shop.php">Shop</a> |
<a href="cart.php">View Cart</a> |
<a href="forum.php">Forum</a> |
<a href="home.php">Home</a> |
<a href="goodbye.php">Logout</a></p>' ;

include ( 'includes/footer.html' ) ;

?>
4

1 回答 1

2
echo '<p>A '.$row["item_name"].
   'has been added to your cart</p>. ; <-- forgot closing quote
}
于 2013-11-01T15:24:54.957 回答