#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13

    Webid php error help


    Hi

    I am using webid for a website I am doing for a customer and have added some extra fields to the sell item page and just before I submit it, the data I entered is not showing up in the confirm listing bit and was wondering if anyone could point me in the right direction, I did check the error log and found this but am bit unsure what to change or alter

    PHP Parse error: syntax error, unexpected ')', expecting '&' or T_STRING or T_VARIABLE or '$' in /home/sites/247autotrade.com/public_html/sell.php on line 551, referer: http://247autotrade.com/select_category.php

    Below is line 551 from the coding

    foreach ($system->SETTINGS['make'] as $key => $val)

    That line is taken from the following

    // MAKE
    $TPL_make = '<input type="text" name="make" size="25">' . "\n";
    foreach ($system->SETTINGS['make'] as $key => $val)
    {
    //$TPL_item_condition .= "\t" . '<option value="' . $key . '" ' . (($key == $condition) ? 'selected="true"' : '') . '>' . $val . '</option>' . "\n";
    }
    $TPL_make .= '</input>' . "\n";

    I have a screenshot if anyone needs to see the screenshot of the issue
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,932
    Rep Power
    533
    You probably have an open quote somewhere before line 551, but it isn't manifesting into an error until that line. When this happens to me, I typically comment out large sections of code until I identify the culprit.
  4. #3
  5. Recovering Intellectual
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    1,306
    Rep Power
    785
    That ternary operator looks dicey but it may be ok - id try that on another line in the php code and then storing that into a variable. Then use the variable substituted into the string.

    Also php has a nifty thing that allows you to safely string substitue variables. For example:

    "<option>{$variable}</option>" or even "<option>{$variable['key']}</option>"

    So my thoughts are - can you show us the $system class? Are we sure SETTINGS is an array? Need to know whats going on there because as it stands the rest of the syntax looks OK to me. If there is a problem with the foreach statement then I'd make sure the class member reference is kosher first.
    Bugs that go away by themselves come back by themselves
    Beware - your loyalty will not be rewarded
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Hi Matt

    Is the following what you are looking for when you say about showing the $system class

    // make
    $system->SETTINGS['make'] = array (
    1 => $MSG['1036']
    );
  8. #5
  9. Recovering Intellectual
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    1,306
    Rep Power
    785
    Well ... no. When I am asking to see an instance variable's class, I am asking to see the class. Not an assignment operation of an instance variable's property.

    A class, if you need to be reminded, usually starts something similar to:

    Code:
    class MySampleClass {
    
      $classAttr1 = "some value";
      $classAttr2 = array("key" => 0, "etc" => 1);
    
      public function sampleFunction() {
        // does nothing
        return (bool) False;
      }
    }
    Bugs that go away by themselves come back by themselves
    Beware - your loyalty will not be rewarded
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Hmm checked all the files and could not see anything starting with class

    This is the closest thing I could find

    'MAKE' => ($auction_data) ? $system->SETTINGS['make'][$make] : $MSG['933'],
    'MAKE' => $make,

    OR this bit

    'MAKE' => $system->SETTINGS['make'][$make],
    'MAKE_PLAIN' => $make,

    Sorry
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,932
    Rep Power
    533
    ianhaney, What you are experiencing is very common. The below code works without errors which indicates that the script you posted is not the problem. As indicated by the error, you have a PHP Parse error: syntax error. Your script comes to the ')', but expects a '&' or T_STRING or T_VARIABLE or '$'. It is caused my some syntax error upstream of line 551.

    PHP Code:
    <?php
        $system
    =new stdClass;
        
    $system->SETTINGS=array();
        
    $system->SETTINGS['make']=array(0=>123,1=>321,2=>222);
        
    $condition=2;
        
    $TPL_item_condition=NULL;
        
        
    // MAKE
        
    $TPL_make '<input type="text" name="make" size="25">' "\n";
        foreach (
    $system->SETTINGS['make'] as $key => $val)
        {
            
    $TPL_item_condition .= "\t" '<option value="' $key '" ' . (($key == $condition) ? 'selected="true"' '') . '>' $val '</option>' "\n";
        }
        
    $TPL_make .= '</input>' "\n";
    ?>
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Hi NotionCommotion

    So the error is on another line above line 551, that right?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,932
    Rep Power
    533
    Originally Posted by ianhaney
    So the error is on another line above line 551, that right?
    Yes, I believe so.

    PS. Please wrap your code in PHP tags (between the above # and quote symbols).
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Hmm not 100% sure what I am looking for as is not producing any syntax errors

    Is it possible to send the sell.php file over as a zip file and have a look please
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,932
    Rep Power
    533
    Sure, but can't promise anything.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Thank you appreciate it

    I have attached the sell.php file to this message as a zip file

    Thank you
    Attached Files
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,932
    Rep Power
    533
    ianhaney,

    I did not readily see any syntax or parse errors. I also tried http://www.meandeviation.com/tutoria...k+another+file but it caught no errors.

    Typically, parse errors are caused by missing semicolon to end previous line, invalid variable name (maybe missing the $), or unescaped end-of-input anchor for a regular expression.

    I would recommend adding something like echo('<pre>'.print_r($system->SETTINGS['make'],1).'</pre>'); before line 551, see what it says, look for clues, and keep on going backwards until you find the culprit.
  26. #14
  27. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    no syntax errors on PHP 5.4 either.

    • Activate error messages so that you see them live in the script rather than in some error log.
    • Comment out the line of the error message. What happens?
    • What's your PHP version?

    Apart from that: The code is crap. Looks like it has been written by some kid in the 90s and never been updated since. 1,000 lines of unstructured spaghetti code and no escaping at all may have been acceptable back then. But it's the year 2013 now.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo