I am new to PHP and was learning to query the Amazon database using the script provided online for a PHP web services client. While I get the info fine, its when I attempt to parse the info that I seem to get errors
The info I get from the Amazon.com database is something like this
<I>
stdClass Object
(
[TotalResults] => 822
[TotalPages] => 83
[Details] => Array
(
[0] => stdClass Object
(
=> [url]http://www.amazon.com/...
[Asin] => 0596004478
[ProductName] => Google Hacks
[Catalog] => Book
[Authors] => Array
(
[0] => Tara Calishain
[1] => Rael Dornfest
)
[ReleaseDate] => 01 February, 2003
[Manufacturer] => O'Reilly & Associates
[ImageUrlSmall] => [url]http://images.amazon.com/...[/url]
[ImageUrlMedium] => [url]http://images.amazon.com/...[/url]
[ImageUrlLarge] => [url]http://images.amazon.com/...[/url]
[ListPrice] => $24.95
[OurPrice] => $17.47
[UsedPrice] => $15.95
)
...
</I>
This is stored in $hits and I am parsing this way
foreach ($hits->Details as $hit) {
$ProductName = html_entities($hit->ProductName);
$Authors = join(' and ', $hit->Authors);
print $ProductName;
print <<< HTMLBLOCK
<b>$ProductName</b><br/>
HTMLBLOCK;
}
The problem I am facing is the HTMLBLOCK. If I uncomment the entire block it works fine and $ProductName gets printed. But if I include the block an erro "Invalid argument supplied for foreach()" is thrown
Could anybody please tell me what I am doing wrong? Any suggestions would really be appreciated
Thanks
Avinash