Reputation: 41595
I am using an external script for my site and i found out that it seems there's a syntax problem when it tries to generate the XML code.
There are no quotes for the 2nd line and it makes the page crashing. How could i solve it? Why did it work for other people? Is it about the PHP version?
$h->xmlrequest = '<?xml version="1.0"?>';
$h->xmlrequest .= <<<END
<a:searchrequest xmlns:a="DAV:" xmlns:s="http://schemas.microsoft.com/exchange/security/">
<a:sql>
SELECT "DAV:displayname"
,"urn:schemas:httpmail:subject"
FROM "$exchange_server/Exchange/aaaaa/inbox"
</a:sql>
</a:searchrequest>
END;
The problem makes the PHP file not ableto be executed and therefore not showing any external output. Even just trying this makes it crash:
$h->xmlrequest = '<'.'?xml version="1.0"?'.'>';
$h->xmlrequest .= <<<END
END;
Displaying errors this is the error i get:
Parse error: syntax error, unexpected T_SL in C:\inetpub\wwwroot\fromMail\index2.php on line 23
Line 23 is the one of <<< END
Upvotes: 0
Views: 191
Reputation: 82734
Oh, this one is really tricky to spot: You've got spare whitespace at the end of the <<<END
line:
$h->xmlrequest .= <<<END
//----------------------^
Therefore the ending
END;
doesn't match anymore.
Upvotes: 1
Reputation: 14222
You should wrap the $exchange_server
variable name in braces, otherwise although PHP will try to parse it, it can be affected by the code around it.
ie in your case, the slash character after $exchange_server may be confusing the PHP parser.
so...
$h->xmlrequest .= <<<END
<a:searchrequest xmlns:a="DAV:" xmlns:s="http://schemas.microsoft.com/exchange/security/">
<a:sql>
SELECT "DAV:displayname"
,"urn:schemas:httpmail:subject"
FROM "{$exchange_server}/Exchange/aaaaa/inbox"
</a:sql>
</a:searchrequest>
END;
The braces will ensure that the variable is parsed correctly, no matter what is around it.
Hope that helps.
Upvotes: 0
Reputation: 167172
Change:
$h->xmlrequest = '<?xml version="1.0"?>';
To:
$h->xmlrequest = '<'.'?xml version="1.0"?'.'>';
Upvotes: 1
Reputation: 59997
Perhaps change the line
$h->xmlrequest = '<?xml version="1.0"?>';
to
$h->xmlrequest = '<' . '?xml version="1.0"?' . '>';
would do the trick as the parser thinks the ?>
means the end of the PHP script.
Upvotes: 0