SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot soart's Avatar
    Join Date
    Nov 2003
    Location
    Norwich UK
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A right pickle sorting this <form>

    This code has to be iterated within a for loop so as to display 'x' number of items and each item needs to have the ability to be added to a cart.
    The code handling the cart is an include file hence the Add to Cart call.
    Can anyone please tell me where I've gone nuts with my ' and " as I think that may be the error but after many many variations I think I'm repeating myself and perhaps a new pair of eyes may instantly see the error(s)
    Code specifically has an expecting } error reported on the line beginning with the if statement

    snippet
    PHP Code:
        $img = "<td align=center>
        <form action='test.php?".strip_tags(SID)."' method='post'>
        <input type='hidden' value='". $id ."' name='id' />
        <label> <?php 
        $price 
    $price1;  
        
    $ITEM_ID=$title
        
    $DISPLAY_NAME=$p1des
         if(
    $submit  == 'Add to Cart'){$_SESSION['basket']->Add_Item($ITEM_ID,$DISPLAY_NAME,$quantity,$price,$data,$tax,$color,$size,$weight);} ?>
        <img src=thumbs/$filename ></td>
        <td align=center>$ttitle</td>
        <td align=center>$des</td>
        <td align=center><input name='submit' type='submit' value='Add to Cart'>
        </label>
        </form></td>
        <td><a href='shop.php?". strip_tags(SID). "'>View Cart</a></td>\n";
        echo "$img";

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    This line look wrong...
    PHP Code:
    <form action='test.php?".strip_tags(SID)." method='post''
    should it be...
    PHP Code:
    <form action='test.php?".strip_tags(SID)."' method='post'
    S
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot soart's Avatar
    Join Date
    Nov 2003
    Location
    Norwich UK
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah that was one error, getting those ' and " in the right order and place can be troublesome!
    error now is expecting `'}'' in line commencing the if statement, the line is correctly done as far as I can see which suggests to me that enclosing php or ' " are still messed up somewhere

  4. #4
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're going out of php on this line with ?> :
    PHP Code:
     if($submit  == 'Add to Cart'){$_SESSION['basket']->Add_Item($ITEM_ID,$DISPLAY_NAME,$quantity,$price,$data,$tax,$color,$size,$weight);} ?> 
    ... but you keep calling variables after that.

  5. #5
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... also you're stating the if inside the string-type var that is $img.

  6. #6
    SitePoint Zealot soart's Avatar
    Join Date
    Nov 2003
    Location
    Norwich UK
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code snippet is enclosed in a for loop so is all within php tags.
    The <?php call within the string type variable $img is specifically because it is in a string variable so that when ouputted it encloses in php tags the necessary portion of code for operation on actuating the submit button. Thats the theory anyway, the application is whats getting me!

  7. #7
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay well then have all the info you need per product (price, ITEM_ID, DISPLAY_NAME) put into hidden input fields during the loop. After the loop, echo out $img. If a submit button is hit, do your Add_Item routine based on the $_POST id. Or something like that!


Bookmarks

Posting Permissions

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