我的 php 代码有错误
这是我的代码
function cart() {
foreach($_SESSION as $name => $value) {
if ($value>0) {
if (substr($name, 0, 5) == 'cart_'){
$id = substr($name, 5, (strlen($name)-5));
$get = mysql_query('SELECT id, name, price FROM products WHERE id=' .mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)){
$sub = $get_row['price'] * $value;
echo $get_row['name'].' x '.$value.' @ '.get_row['price'].' = '.$sub.'<br />' ;
}
}
}
else{
echo "your cart is empty.";
}
}
}
错误是
Parse error: syntax error, unexpected '[', expecting ',' or ';' in C:\xampp\htdocs\shoppingcart\cart.php on line 39
这是
echo $get_row['name'].' x '.$value.' @ '.get_row['price'].' = '.$sub.'<br />' ;
我认为我的代码是正确的
请帮我
我只是这个领域的新手
谢谢