Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Invalid argument supplied for foreach() error
Old 03-20-2005, 06:34 PM Invalid argument supplied for foreach() error
Junior Talker

Posts: 1
Trades: 0
Hi Everybody,
I am new to PHP so please bear with me .
I was studying about a particular script involving querying the Amazon database using the client and parsing the info obtained
The info I obtained was in the form

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] => http://images.amazon.com/...
[ImageUrlMedium] => http://images.amazon.com/...
[ImageUrlLarge] => http://images.amazon.com/...[ListPrice] => $24.95
[OurPrice] => $17.47
[UsedPrice] => $15.95
)

.....
)

)

This was stored in a variable $hits. That was then parsed using the following code
The entire code for this is
<?php
require_once 'SOAP/Client.php';

$wsdl_url =
'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl';
$WSDL = new SOAP_WSDL($wsdl_url);
$client = $WSDL->getProxy();

$params = array(
'manufacturer' => "O'Reilly",
'mode' => 'books',
'sort' => '+title',
'page' => 1,
'type' => 'lite',
'tag' => 'XXXX',
'devtag' => 'XXXXXXXXXXXXXX',
);

$hits = $client->ManufacturerSearchRequest($params);

foreach ($hits->Details as $hit) {
$ProductName = html_entities($hit->ProductName);
$Authors = join(' and ', $hit->Authors);

print <<< _HTML_
<div style="clear:left; width: 300px; padding:5px;
margin:5px; background:#ddd;">
<a href="$hit->Url"><image src="$hit->ImageUrlSmall"
alt="$ProductName" align="left"></a>
<b>$ProductName</b><br/>
By $Authors<br/>
Amazon.com Price: $hit->OurPrice<br/>
</div>
_HTML_;
}
?>

But this doesnt seem to run. It gives me a Invalid argument supplied for foreach() error.
I tried commenting out the _HTML_ here document and it worked fine. I am unable to debug what exactly is wrong with the here document. COuld any of you guys please help me out? I have almost spent 5hrs on researching this but have been unsuccessful.
Any suggestions would be appreciated

Thanks a lot
Avinash

Last edited by avinashp; 03-20-2005 at 06:38 PM..
avinashp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Invalid argument supplied for foreach() error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08930 seconds with 12 queries