When I try to run this php file in a browser, I get an error message -


when try run php file in browser, error message: "parse error: syntax error, unexpected ')', expecting :: (t_paamayim_nekudotayim)" on line 50"

i have red on lines 54 , 55 can't rid of. 2 lines, error tool tip says, "syntax error: expected: ::,("

as far can see, of curly braces need be. don't know what's wrong. ideas? here's code:

    <?php  //if session not in progress user, start one: if(!session_id()){     session_start(); }  ?> <!doctype html> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=utf-8">         <title>shopping cart manager</title>         <link href="css/minismall.css" rel="stylesheet">     </head>     <body>         <?php         //check if session cart variable exists , set shortcut:         if (isset($_session['cart'])) {         $cart = $_session['cart'];         }         else {  // $_session['cart'] not exist         $cart = array();         }          include 'catalog.php';          //check if ‘remove’ form field exists , set shortcut:         if (isset($_post['remove'])) {             $remove = $_post['remove'];     }     else {//$_post['remove'] not exist             $remove = array();     }          //initialize $totalprice, $prodidstr, , session ‘numitems’ variables         //either 0 or empty string appropriate:         $totalprice = 0;         $prodidstr = "";         $_session[numitems] = 0;//did initialize session variable correctly?         //$_session['numitems'] = $numitems;          //loop through each form field (this page called catalog.php):                  //if form field’s value (product quantity) positive number     //(nonzero), not submit button, , remove checkbox      //removing product has not been checked (do these checks in 1         //condition):                 while (list($productid,$qty) = each($_post)){             if (($qty > 0) && (type != submit) && !isset(checkbox)){//line 50                  $cat[$productid]['qty']+=$qty;//update cart's element                 //this product product quantity form             }//line 54             else if (($qty = 0) || isset(checkbox)){//if product's quantity             //is 0 or product's remove checkbox checked              //remove product cart array:             //unset($_session['cart'][$productid]);             unset($cart['productid']['qty']);              }//end of else if                  }//end of while loop          //connect db server , select database:         require 'dbconnect.php';           //loop through cart array (foreach productid's quantity in cart):          $_session['numitems'] = $cart;//update number of items in cart           //build comma-delimited string in $prodidstr containing product          //id’s of products in our cart array:          $prodidstr = implode("productid, qty", $cart);            if($_session[numitems] = 0){//if cart empty:              print "<h3>your shopping cart empty!</h3>\n";          }          else{//if cart not empty:           //remove trailing comma $prodidstr:           //query db products in our cart using $prodidstr ordering          //them category , productid:                 try {             $prodidstr = $pdo->query("select * $cart order $cat , $productid");         }         catch (pdoexception $e) {             $error = "error fetching product info category $cat: " . $e->getmessage();             include 'error.html.php';             exit();         }          //display beginning of form calls cart_yourname.php when submitted         //using post method:         ?>         <form action="cart_speterson86.php" method="post">              <table>                  <tr class="header">                     <th>remove</th>                     <th>image</th>                     <th>description</th>                     <th>price - us$</th>                     <th>subtotal</th>                     <th>quantity</th>                     <th style="background-color: #fff">&nbsp;</th>                 </tr>          <?php          //         // step through result set of products in category ,         // display each product in own table row         //         while ($row = $itemsresult->fetch()) {              // convert special html characters html             // entities.  example: & --> &amp;             //             // also, strip out html tags found in data             $remove = htmlspecialchars(strip_tags($row['loc']));             $imagelocation = htmlspecialchars(strip_tags($row['loc']));             $desc = htmlspecialchars(strip_tags($row['description']));             $price = htmlspecialchars(strip_tags($row['price']));             $subtotal = htmlspecialchars(strip_tags($row['loc']));              $price = "\$" . number_format($price, 2);              $productid = strip_tags($row['prodid']);              //             // set $qty contain in our session cart array.             // if session cart array element product              // empty, set $qty default value of 0.             //             if (isset($_session['cart'][$productid])) {                 $qty = $_session['cart'][$productid];             }             else {                 $qty = 0;             }               // build , display next product row in table             print <<<tabrow                  <tr>                     <td><input type="checkbox" name="$remove[$productid]" value="1"></td>                     <td><img src="$imagelocation" alt="groovy product $desc"></td>                     <td class="desc">$desc</td>                     <td class="price">$price</td>                     <td class="price">$subtotal</td>                     <td class="qty">                         <label for="quantityforproduct$productid">qty</label>                         <input type="text" name="$productid" id="quantityforproduct$productid" value="$qty" size="3">                                             </td>                  </tr>  tabrow;          }  // end while row in product result set          ?>                 <tr>                     <td colspan="4" id="submitcell">                         <input type="submit" name="addcart" value="add items cart">                     </td>                     <td><input type="submit" name="checkout" value="checkout"></td>                     <td><input type="submit" name="updatecart" value="update cart"></td>                 </tr>              </table>         </form>         <br>         <?php             }//end of else cart not empty            ?>     </body> </html> 

$_session[numitems] = 0;//did initialize session should have single quotes?.


Comments