By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

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

100+
P: 123
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....


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. class S_Shipping  {
  4.         // Private variables.
  5.         var $_access_key;
  6.         var $_username;
  7.         var $_password;
  8.         var $_request_option;
  9.         var $_ups_url;
  10.         var $_xml_request;
  11.         var $_xml_response;
  12.  
  13.         function kS_Shipping() {
  14.                 // Set defaults.
  15.                 $this->_access_key                      = "";
  16.                 $this->_username                        = "";
  17.                 $this->_password                        = "";
  18.                 $this->_request_option                  = "rate";
  19.                 $this->_ups_url                         = "";
  20.         }
  21.  
  22.         function getRate(
  23.                 $package_weight,
  24.                 $shipto_postal_code,
  25.                 $shipto_country = "US",
  26.                 $service_code = ""
  27.         )  {
  28.  
  29.               // commented out  $residential = "<ResidentialAddressIndicator/>";
  30.                 $residential = "";
  31.  
  32. $this->_xml_request = <<<XML 
  33.  
  34. <?xml version="1.0"?>
  35. <AccessRequest xml:lang="en-US">
  36.    <AccessLicenseNumber>{$this->_access_key}</AccessLicenseNumber>
  37.    <UserId>{$this->_username}</UserId>
  38.    <Password>{$this->_password}</Password>
  39. </AccessRequest>
  40. <?xml version="1.0"?>
  41. <RatingServiceSelectionRequest xml:lang="en-US">
  42.        <Request>
  43.               <TransactionReference>
  44.                  <CustomerContext> Shipping</CustomerContext>
  45.                  <XpciVersion>1.0001</XpciVersion>
  46.               </TransactionReference>
  47.       <RequestAction>{$this->_request_option}</RequestAction>
  48.       <RequestOption>{$this->_request_option}</RequestOption>
  49.        </Request>
  50.        <PickupType>
  51.           <Code>01</Code>
  52.        </PickupType>
  53.    <Shipment>
  54.           <Shipper>
  55.              <Name>Office</Name>
  56.              <TaxIdentificationNumber>9</TaxIdentificationNumber>
  57.                  <PhoneNumber></PhoneNumber>
  58.                  <FaxNumber></FaxNumber>
  59.                  <ShipperNumber></ShipperNumber>
  60.              <Address>
  61.                     <PostalCode></PostalCode>
  62.                     <CountryCode>US</CountryCode>
  63.                  </Address>
  64.           </Shipper>
  65.             <ShipTo>
  66.              <Address>
  67.                 <PostalCode>{$shipto_postal_code}</PostalCode>
  68.                 <CountryCode>{$shipto_country}</CountryCode>
  69.           <residential> {$residential}</residential>
  70.          </Address>
  71.           </ShipTo>
  72.           <ShipFrom>
  73.              <Address>
  74.             <PostalCode></PostalCode>
  75.             <CountryCode></CountryCode>
  76.              </Address>
  77.           </ShipFrom>
  78.           <Service>
  79.          <Code>{$service_code}</Code>
  80.           </Service>
  81.           <Package>
  82.              <PackagingType>
  83.                 <Code>02</Code>
  84.              </PackagingType>
  85.              <PackageWeight>
  86.                 <UnitOfMeasurement>
  87.                    <Code>LBS</Code>
  88.                 </UnitOfMeasurement>
  89.                     <Weight>{$package_weight}</Weight>
  90.              </PackageWeight>
  91.           </Package>
  92.       <RateInformation>
  93.      <NegotiatedRatesIndicator/>
  94.       </RateInformation>
  95.    </Shipment>
  96. </RatingServiceSelectionRequest>
  97.  
  98. XML;
  99.  
  100.  
  101.  
  102.         $http = curl_init() or die(curl_error());
  103.                 curl_setopt($http, CURLOPT_URL , $this->_ups_url);
  104.                 curl_setopt($http, CURLOPT_HEADER, false);
  105.                 curl_setopt($http, CURLOPT_POST, true);
  106.                 curl_setopt($http, CURLOPT_POSTFIELDS, $this->_xml_request);
  107.                 curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
  108.                 $this->_xml_response = curl_exec($http);
  109.                 curl_close($http);
  110.  
  111. //              $xml = new SimpleXMLElement($xml_response);
  112.                 return(XML_unserialize($this->_xml_response));
  113.  
  114.         }
  115. }
  116.  
  117. ?>
  118.  
Jun 2 '08 #1
Share this Question
Share on Google+
9 Replies


Atli
Expert 5K+
P: 5,058
When I ran your code on my server (PHP 5.2.4) I got this error:
Expand|Select|Wrap|Line Numbers
  1. 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?
Jun 2 '08 #2

100+
P: 123
When I ran your code on my server (PHP 5.2.4) I got this error:
Expand|Select|Wrap|Line Numbers
  1. 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..?
Jun 2 '08 #3

Markus
Expert 5K+
P: 6,050
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.
Jun 2 '08 #4

Atli
Expert 5K+
P: 5,058
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.
Jun 3 '08 #5

pbmods
Expert 5K+
P: 5,821
Heya, AJD.

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

Expand|Select|Wrap|Line Numbers
  1. )  {
Did an extra function declaration go in there?
Jun 3 '08 #6

Atli
Expert 5K+
P: 5,058
Heya, AJD.

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

Expand|Select|Wrap|Line Numbers
  1. )  {
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
Expand|Select|Wrap|Line Numbers
  1. class S_Shipping
  2. {
  3.         function getRate(
  4.                 $package_weight,
  5.                 $shipto_postal_code,
  6.                 $shipto_country = "US",
  7.                 $service_code = ""
  8.         )  { # Line 26
  9.           #... The big string is here.
  10.         }
  11. }
  12.  
Jun 3 '08 #7

100+
P: 123
Hey all,
It did worked....Thanks
Jun 5 '08 #8

TheServant
Expert 100+
P: 1,168
Hey all,
It did worked....Thanks
Can you post the solution so that others can learn from it please.
Jun 5 '08 #9

100+
P: 123
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...
Jun 6 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.