|
-
Apr 9th, 2010, 08:15 AM
#1
Thread Starter
Fanatic Member
Parse error: syntax error, unexpected $end
I found this code that I want to adapt for a project that I am working on and I cannot figure out where the issue is. I have end ; on each line, my single quotes all are good, and I only have one set of curly brackets...I need HELP!!
Code:
<?php
function validateAddress(){
$xmlstr = <<<XML
<AddressValidateRequest USERID="XXXXXXXXX">
<Address ID="0">
<Address1></Address1>
<Address2></Address2>
<City></City>
<State></State>
<Zip5></Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>
XML;
$xml = new SimpleXMLElement($xmlstr);
$h = new http();
// Populate Address
$xml->Address->Address2 = 'MyAddress';
$xml->Address->Address1 = '';
$xml->Address->City = 'MyCity';
$xml->Address->State = 'MYState';
$xml->Address->Zip5 = 'MyZip';
// Prepare for XML call
$h->xmlrequest = $xml->asXML();
$output = str_replace(array("\n",'<?xml version="1.0"?>',"\t",),array('','',''), $xml->asXML());
$url = 'http://TESTING.ShippingAPIs.com/ShippingAPItest.dll?API=Verify&XML='.urlencode($output);
// Submit data and get results
$h->fetch($url,0,'','','','GET');
print_r($h->body); die();
// Put results into XML object
$xml = new SimpleXMLElement($h->body);
return $xml;
}
$xmlverify = validateAddress();
print_r($xmlverify);
?>
Thanks in advance!! 
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Apr 9th, 2010, 11:02 AM
#2
Re: Parse error: syntax error, unexpected $end
When you use the heredoc syntax to delimit a string, you can't have any whitespace preceding the closing delimiter. So you need to do it like this:
Code:
$xmlstr = <<<XML
<AddressValidateRequest USERID="XXXXXXXXX">
<Address ID="0">
<Address1></Address1>
<Address2></Address2>
<City></City>
<State></State>
<Zip5></Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>
XML;
Or, just use single quotes to define the string...
Once that's fixed, your next error is "Class 'http' not found."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|