添加购物车中的语法错误

时间:2013-11-01 15:23:52

标签: php

当我尝试将商品添加到购物车时,我收到“Parse error:syntax error,unexpected'>'在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' ) ;

?>

1 个答案:

答案 0 :(得分:2)

echo '<p>A '.$row["item_name"].
   'has been added to your cart</p>. ; <-- forgot closing quote
}