parse error, unexpected T_STRING?

Discussion in 'PHP' started by Tulumbo, Nov 23, 2007.

  1. #1
    Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/t/u/l/tulumbo/html/browse.php on line 356

    I am getting this warning on my website. I know this is probably very simple but I am a php newbie. Please help. Here is line 356:

    public $status = 0; // HTTP status code
     
    Tulumbo, Nov 23, 2007 IP
  2. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #2
    are you using php5 and inside a class?
     
    serialCoder, Nov 23, 2007 IP
  3. Tulumbo

    Tulumbo Active Member

    Messages:
    712
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    70
    #3
    yes and yes. thanks for the quick response.

    class cURL {

    # Debug data
    # public $cookiesSent = array();
    # public $cookies = array();
    # public $posted = '';
    # End debug
    public $status = '0'; // HTTP status code
    public $headers = array(); // Record headers for later use
    public $error = false; // Hold cURL error
    public $abort = false; // Our errors / reason for abortion
    public $return; // Store the return
    public $proxyOptions = array(); // Store our proxy browsing options
    public $docType = 0; // Corresponding parser (from content type)
    public $cacheName; // Name of cache file to save as (false for no cache)
    public $fileHandle; // Handle for cache file
    public $length = 0;
    private $endHeaders = true; // Flag for end of headers, checked in readBody

    public function __construct($toLoad,$curlOptions,$options,$cache) {
    // Set proxy options
    $this->proxyOptions = $options;
    // And cache name
    $this->cacheName = $cache;

    # Debug
    # $this->posted = isset($curlOptions[CURLOPT_POSTFIELDS]) ? $curlOptions[CURLOPT_POSTFIELDS] : '';
    # $this->cookiesSent = isset($curlOptions[CURLOPT_COOKIE]) ? $curlOptions[CURLOPT_COOKIE] : array();
    # End debug

    // Set our callbacks
    $curlOptions[CURLOPT_HEADERFUNCTION] = array(&$this,'readHeaders');
    $curlOptions[CURLOPT_WRITEFUNCTION] = array(&$this,'readBody');

    // Start curl handle
    $tmp = curl_init($toLoad);

    // Set our options
    if ( function_exists('curl_setopt_array') )
    curl_setopt_array($tmp,$curlOptions);
    else
    foreach ( $curlOptions as $option => $value )
    curl_setopt($tmp,$option,$value);

    // Get return
    curl_exec($tmp);

    // Close file handle
    if ( $this->fileHandle ) {

    fclose($this->fileHandle);
    $this->fileHandle = false;

    // Rename tmp to real name
    rename(optCACHEPATH . 'tmp.'.$this->cacheName, optCACHEPATH.$this->cacheName);

    }

    // Record errors
    $this->error = curl_error($tmp);

    // Close cURL
    curl_close($tmp);
    }
     
    Tulumbo, Nov 23, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    What version of PHP are you using? If you're unsure, run this and see what you get:
    
    <?php
    echo phpversion();
    ?>
    
    PHP:
    If it's 4.x.x, then replace all "public"s (and "private" and "protected", if any) with "var".

    If it's 5+.. then post your full code.
     
    nico_swd, Nov 23, 2007 IP
  5. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #5
    hmm, can you please post the entire code?
     
    serialCoder, Nov 23, 2007 IP
  6. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #6
    if it's 4.x.x, then replace all "public"s (and "private" and "protected", if any) with "var"

    hmm, i think in php 4 that will give an error.
     
    serialCoder, Nov 23, 2007 IP
  7. Tulumbo

    Tulumbo Active Member

    Messages:
    712
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    70
    #7
    entire code is posted above ^^^^^
     
    Tulumbo, Nov 23, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    Try this. Should be PHP 4 compatible
    
    class cURL {
    
    # Debug data
    # public $cookiesSent = array();
    # public $cookies = array();
    # public $posted = '';
    # End debug
    var $status = '0'; // HTTP status code
    var $headers = array(); // Record headers for later use
    var $error = false; // Hold cURL error
    var $abort = false; // Our errors / reason for abortion
    var $return; // Store the return
    var $proxyOptions = array(); // Store our proxy browsing options
    var $docType = 0; // Corresponding parser (from content type)
    var $cacheName; // Name of cache file to save as (false for no cache)
    var $fileHandle; // Handle for cache file
    var $length = 0;
    var $endHeaders = true; // Flag for end of headers, checked in readBody
    
    function cURL($toLoad,$curlOptions,$options,$cache) {
    // Set proxy options
    $this->proxyOptions = $options;
    // And cache name
    $this->cacheName = $cache;
    
    # Debug
    # $this->posted = isset($curlOptions[CURLOPT_POSTFIELDS]) ? $curlOptions[CURLOPT_POSTFIELDS] : '';
    # $this->cookiesSent = isset($curlOptions[CURLOPT_COOKIE]) ? $curlOptions[CURLOPT_COOKIE] : array();
    # End debug
    
    // Set our callbacks
    $curlOptions[CURLOPT_HEADERFUNCTION] = array(&$this,'readHeaders');
    $curlOptions[CURLOPT_WRITEFUNCTION] = array(&$this,'readBody');
    
    // Start curl handle
    $tmp = curl_init($toLoad);
    
    // Set our options
    if ( function_exists('curl_setopt_array') )
    curl_setopt_array($tmp,$curlOptions);
    else
    foreach ( $curlOptions as $option => $value )
    curl_setopt($tmp,$option,$value);
    
    // Get return
    curl_exec($tmp);
    
    // Close file handle
    if ( $this->fileHandle ) {
    
    fclose($this->fileHandle);
    $this->fileHandle = false;
    
    // Rename tmp to real name
    rename(optCACHEPATH . 'tmp.'.$this->cacheName, optCACHEPATH.$this->cacheName);
    
    }
    
    // Record errors
    $this->error = curl_error($tmp);
    
    // Close cURL
    curl_close($tmp);
    }
    
    PHP:
     
    nico_swd, Nov 23, 2007 IP
  9. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #9
    sorry, i was using the quickpost :(

    you seemed to be missing the closing } for the class
     
    serialCoder, Nov 23, 2007 IP
  10. Tulumbo

    Tulumbo Active Member

    Messages:
    712
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    70
    #10
    ok...i see that I have three { ......... but only two } so that makes sense. where am i missing the one }??
     
    Tulumbo, Nov 23, 2007 IP
  11. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You are missing it at the very end.
     
    hogan_h, Nov 23, 2007 IP
  12. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #12
    If people just read the errors:

    Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in

    Parse errors only occur when something is in the wrong place or something is missing.

    As the error above states, you are missing a } in your code, which it was expecting. Trace your code for the error.

    Peace,
     
    Barti1987, Nov 23, 2007 IP
  13. pretender

    pretender Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Hi all

    I am having a similiar problem I keep getting this error:parse error: syntax error, unexpected $end, expecting ')' in /home/multespo/public_html/shops/admin/index.php on line 40

    Aany help would be a great help

    The code is below;



    <?php
    /*
    $Id: index.php,v 1.19 2003/06/27 09:38:31 dgw_ Exp $

    osCommerce, Open Source E-Commerce Solutions
    http://www.oscommerce.com

    Copyright (c) 2006 osCommerce

    Released under the GNU General Public License
    */

    require('includes/application_top.php');

    $cat = array(array('title' => BOX_HEADING_CONFIGURATION,
    'image' => 'configuration.gif',
    'href' => tep_href_link(FILENAME_CONFIGURATION, 'selected_box=configuration&gID=1'),
    'children' => array(array('title' => BOX_CONFIGURATION_MYSTORE, 'link' => tep_href_link(FILENAME_CONFIGURATION, 'selected_box=configuration&gID=1')),
    array('title' => BOX_CONFIGURATION_LOGGING, 'link' => tep_href_link(FILENAME_CONFIGURATION, 'selected_box=configuration&gID=10')),
    array('title' => BOX_CONFIGURATION_CACHE, 'link' => tep_href_link(FILENAME_CONFIGURATION, 'selected_box=configuration&gID=11')))),
    array('title' => BOX_HEADING_MODULES,
    'image' => 'modules.gif',
    'href' => tep_href_link(FILENAME_MODULES, 'selected_box=modules&set=payment'),
    'children' => array(array('title' => BOX_MODULES_PAYMENT, 'link' => tep_href_link(FILENAME_MODULES, 'selected_box=modules&set=payment')),
    array('title' => BOX_MODULES_SHIPPING, 'link' => tep_href_link(FILENAME_MODULES, 'selected_box=modules&set=shipping')))),
    array('title' => BOX_HEADING_CATALOG,
    'image' => 'catalog.gif',
    'href' => tep_href_link(FILENAME_CATEGORIES, 'selected_box=catalog'),
    'children' => array(array('title' => CATALOG_CONTENTS, 'link' => tep_href_link(FILENAME_CATEGORIES, 'selected_box=catalog')),
    array('title' => BOX_CATALOG_MANUFACTURERS, 'link' => tep_href_link(FILENAME_MANUFACTURERS, 'selected_box=catalog')))),
    array('title' => BOX_HEADING_LOCATION_AND_TAXES,
    'image' => 'location.gif',
    'href' => tep_href_link(FILENAME_COUNTRIES, 'selected_box=taxes'),
    'children' => array(array('title' => BOX_TAXES_COUNTRIES, 'link' => tep_href_link(FILENAME_COUNTRIES, 'selected_box=taxes')),
    array('title' => BOX_TAXES_GEO_ZONES, 'link' => tep_href_link(FILENAME_GEO_ZONES, 'selected_box=taxes')))),
    array('title' => BOX_HEADING_CUSTOMERS,
    'image' => 'customers.gif',
    'href' => tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers'),
    'children' => array(array('title' => BOX_CUSTOMERS_CUSTOMERS, 'link' => tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers')),
     
    pretender, Dec 28, 2007 IP
  14. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #14
    What did you edit exactly? look there..
     
    DarkMindZ, Dec 28, 2007 IP
  15. pretender

    pretender Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I have not edited any code
     
    pretender, Dec 28, 2007 IP
  16. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #16
    So you just downloaded OsCommerce and it had errors? doesnt make sense ;S
     
    DarkMindZ, Dec 28, 2007 IP
  17. pretender

    pretender Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    I have had it downloaded for a while now and it keeps coming up with different parse errors.I fix one line of code and than the error moves to another line.
     
    pretender, Dec 28, 2007 IP
  18. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #18
    ok, download a fresh one, better :)
     
    DarkMindZ, Dec 28, 2007 IP
  19. pretender

    pretender Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    ok.thanks for your help
     
    pretender, Dec 28, 2007 IP