Parse error: syntax error, unexpected $end in............

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    Parse error: syntax error, unexpected $end in............

    Hi all...
    I am getting an error Parse error: syntax error, unexpected $end in http:/..... on line 117...(117 is the EOF)..
    can you plz help me out..I have checked out for the < , > ,{ ,} etc....
    I donno where m wrong....


    [code=php]
    <?php
    class S_Shipping {
    // Private variables.
    var $_access_key;
    var $_username;
    var $_password;
    var $_request_optio n;
    var $_ups_url;
    var $_xml_request;
    var $_xml_response;

    function kS_Shipping() {
    // Set defaults.
    $this->_access_key = "";
    $this->_username = "";
    $this->_password = "";
    $this->_request_optio n = "rate";
    $this->_ups_url = "";
    }

    function getRate(
    $package_weight ,
    $shipto_postal_ code,
    $shipto_country = "US",
    $service_code = ""
    ) {

    // commented out $residential = "<ResidentialAd dressIndicator/>";
    $residential = "";

    $this->_xml_request = <<<XML

    <?xml version="1.0"?>
    <AccessReques t xml:lang="en-US">
    <AccessLicenseN umber>{$this->_access_key} </AccessLicenseNu mber>
    <UserId>{$thi s->_username}</UserId>
    <Password>{$thi s->_password}</Password>
    </AccessRequest>
    <?xml version="1.0"?>
    <RatingServiceS electionRequest xml:lang="en-US">
    <Request>
    <TransactionRef erence>
    <CustomerContex t> Shipping</CustomerContext >
    <XpciVersion>1. 0001</XpciVersion>
    </TransactionRefe rence>
    <RequestAction> {$this->_request_optio n}</RequestAction>
    <RequestOption> {$this->_request_optio n}</RequestOption>
    </Request>
    <PickupType>
    <Code>01</Code>
    </PickupType>
    <Shipment>
    <Shipper>
    <Name>Office</Name>
    <TaxIdentificat ionNumber>9</TaxIdentificati onNumber>
    <PhoneNumber> </PhoneNumber>
    <FaxNumber></FaxNumber>
    <ShipperNumber> </ShipperNumber>
    <Address>
    <PostalCode></PostalCode>
    <CountryCode>US </CountryCode>
    </Address>
    </Shipper>
    <ShipTo>
    <Address>
    <PostalCode>{$s hipto_postal_co de}</PostalCode>
    <CountryCode>{$ shipto_country} </CountryCode>
    <residential> {$residential}</residential>
    </Address>
    </ShipTo>
    <ShipFrom>
    <Address>
    <PostalCode></PostalCode>
    <CountryCode> </CountryCode>
    </Address>
    </ShipFrom>
    <Service>
    <Code>{$service _code}</Code>
    </Service>
    <Package>
    <PackagingTyp e>
    <Code>02</Code>
    </PackagingType>
    <PackageWeigh t>
    <UnitOfMeasurem ent>
    <Code>LBS</Code>
    </UnitOfMeasureme nt>
    <Weight>{$packa ge_weight}</Weight>
    </PackageWeight>
    </Package>
    <RateInformatio n>
    <NegotiatedRate sIndicator/>
    </RateInformation >
    </Shipment>
    </RatingServiceSe lectionRequest>

    XML;



    $http = curl_init() or die(curl_error( ));
    curl_setopt($ht tp, CURLOPT_URL , $this->_ups_url);
    curl_setopt($ht tp, CURLOPT_HEADER, false);
    curl_setopt($ht tp, CURLOPT_POST, true);
    curl_setopt($ht tp, CURLOPT_POSTFIE LDS, $this->_xml_request );
    curl_setopt($ht tp, CURLOPT_RETURNT RANSFER, true);
    $this->_xml_respons e = curl_exec($http );
    curl_close($htt p);

    // $xml = new SimpleXMLElemen t($xml_response );
    return(XML_unse rialize($this->_xml_response) );

    }
    }

    ?>
    [/code]
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    When I ran your code on my server (PHP 5.2.4) I got this error:
    Code:
    Parse error: syntax error, unexpected T_SL in /var/www/Test/test.php on line 31
    I found an extra white-space after the "<<<XML" in line 31.
    Once I removed that I got no more complaints.

    Could that be the problem?

    Comment

    • ajd335
      New Member
      • Apr 2008
      • 123

      #3
      Originally posted by Atli
      When I ran your code on my server (PHP 5.2.4) I got this error:
      Code:
      Parse error: syntax error, unexpected T_SL in /var/www/Test/test.php on line 31
      I found an extra white-space after the "<<<XML" in line 31.
      Once I removed that I got no more complaints.

      Could that be the problem?
      Hi Atli,
      Thanks ....I have an extra space...
      Bt still I am getting the error of ...

      Fatal error: Call to undefined function curl_init() in /home/ajd/web/ps.php...
      why I am getting that error..?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Most likely curl isn't enabled!

        Make a php file named phpinfo.php then inside the file have
        [php]
        <?php
        phpinfo();
        ?>
        [/php]
        Then navigate to the file in your browser. Look for a part about curl.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Yea, your PHP installation is most likely missing the cUrl extension.
          To make sure, try Markus' code. If there is no mention of cUrl, it is indeed missing.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, AJD.

            What's with the extra curly brace on line 26?

            [code=php]) {[/code]

            Did an extra function declaration go in there?

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Originally posted by pbmods
              Heya, AJD.

              What's with the extra curly brace on line 26?

              [code=php]) {[/code]

              Did an extra function declaration go in there?
              Its' not extra, the parameters are just spread over a few lines there.
              I do the same thing when I have a lot of parameters :P
              [code=php]
              class S_Shipping
              {
              function getRate(
              $package_weight ,
              $shipto_postal_ code,
              $shipto_country = "US",
              $service_code = ""
              ) { # Line 26
              #... The big string is here.
              }
              }
              [/code]

              Comment

              • ajd335
                New Member
                • Apr 2008
                • 123

                #8
                Hey all,
                It did worked....Thank s

                Comment

                • TheServant
                  Recognized Expert Top Contributor
                  • Feb 2008
                  • 1168

                  #9
                  Originally posted by ajd335
                  Hey all,
                  It did worked....Thank s
                  Can you post the solution so that others can learn from it please.

                  Comment

                  • ajd335
                    New Member
                    • Apr 2008
                    • 123

                    #10
                    Originally posted by TheServant
                    Can you post the solution so that others can learn from it please.

                    Hi TheServant ,
                    Errors in my code are due to ,
                    1) an extra space after the $this->_xml_request =<<<XML
                    2) And my curl_ini was ON but the root directory on which it was relaying was broken.....So fixed that up..

                    But , as i have seen so far CURL error is just due to having Curl not enable .You can see the status of Curl making a.php and adding function php_info()..
                    Good luck...

                    Comment

                    Working...