www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP error

  1. #1
    Join Date
    Nov 2006
    Posts
    75

    PHP error

    I have a form and the action is a script that is returning the error:

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/gwilliam/public_html/thomasju/addtofinalorder.php on line 22

    line 22 is the line following

    $addtocart = "insert into final_orders values
    On this Page:
    <CODE>
    if ($_POST[sel_item_id] != "") {
    //validate item and get title and price
    $get_iteminfo = "select item_title from store_items where id = $_POST[sel_item_id]";
    $get_iteminfo_res = mysql_query($get_iteminfo) or die(mysql_error());

    if (mysql_num_rows($get_iteminfo_res) < 1) {
    //invalid id, send away
    header("Location: seestore.php");
    exit;
    } else {
    //get info
    $item_title = mysql_result($get_iteminfo_res,0,'item_title');

    //add info to cart table
    $addtocart = "insert into final_orders values
    ('',
    '$PHPSESSID',
    '$_POST[sel_item_id]',
    '$_POST[sel_item_qty]',
    '$_POST[sel_item_size]',
    '$_POST[sel_item_color]',
    '$_POST[sel_item_size][price]',
    '$_POST[First name]',
    '$_POST[Surname]',
    '$_POST[Email]',
    '$_POST[Address Line1]',
    '$_POST[Address Line2]',
    '$_POST[Address Line3]',
    '$_POST[Town]',
    '$_POST[County]',
    '$_POST[Postcode]',
    '$_POST[Home number]',
    '$_POST[Mobile number]',
    now())";
    mysql_query($addtocart);

    //redirect to showcart page
    header("Location: review_order.php");
    exit;
    }
    } else {
    //send them somewhere else
    header("Location: seestore.php");
    exit;
    }
    ?>
    </CODE>

    Any help would be much appreciated

  2. #2
    Join Date
    Dec 2006
    Location
    Escaz˙ (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    PHP Code:
    <?php
    $addtocart 
    "
      insert into final_orders values (
      '',
      '
    $PHPSESSID',
      '
    {$_POST['sel_item_id']}',
      '
    {$_POST['sel_item_qty]}',
      
    '{$_POST['sel_item_size]}',
      '
    {$_POST['sel_item_color']}',
      '
    {$_POST['sel_item_size']['price']}',
      '
    {$_POST['First name']}',
      '
    {$_POST['Surname']}',
      '
    {$_POST['email']}',
      '
    {$_POST['Address Line1']}',
      '
    {$_POST['Address Line2']}',
      '
    {$_POST['Address Line3']}',
      '
    {$_POST['Town']}',
      '
    {$_POST['County']}',
      '
    {$_POST['Postcode']}',
      '
    {$_POST['Home number']}',
      '
    {$_POST['Mobile number']}',
      now())
    "
    ;
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles