Help me look at the codes below. It has T_IF error and T_WHILE error. The errors are on line 7 and line 18. I hope anyone can teach me to repair it and the code function is still same.
<?php
require_once("db.php");
session_start()
if (!isset($_SESSION['cart'])) { <---T_IF error
$_SESSION['cart'] = array();
}
$handle = mysql_connect("baccesso_web")
or die ("ERROR: Unable to open database!");
$query = "SELECT SKU, Name, Price FROM products";
$result = mysql_query($handle,$query)
or die ("ERROR: Cannot execute $query.");
mysql_error($handle)
if (mysql_num_rows($result)>0) { <--- T_IF error
while ($row = mysql_fetch_object($result)) { <--- T_WHILE error
$sku = $row->Quantity
$productInfo[$sku] = array()
$productInfo[$sku]['Name'] = $row->Name;
$productInfo[$sku]['Price'] = $row->Price;
$productInfo[$sku]['Quantity'] = $row->Quantity;
$productInfo[$sku]['Image'] = $row->Image;
}
} else {
die ("ERROR: Cannot retrieve product information");
}
mysql_close($handle);
switch($_POST['action']) {
case 'add':
foreach ($_POST['addQuantity'] as $sku => $quantity) {
if (isset($quantity) && $quantity > 0) {
$_SESSION['cart'][$sku] += $quantity;
}
}
break;
case 'update':
foreach ($_POST['updateQuantity'] as $sku => $quantity) {
if ($quantity == 0 && trim($quantity) != "") {
unset($_SESSION['cart'][$sku]);
}
if ($quntity > 0) {
$_SESSION['cart'][$sku]=$quantity;
}
}
break;
case 'reset':
$_SESSION['cart'] = array();
break;
}
?>