PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » Services_Amazon » Bug #6605

reference to NULL element

Details

Submitted2006-01-27 14:30 UTC
Fromrenzo dot toma at xs4all dot nl
Assignedttsuruoka
StatusClosed
PackageServices_Amazon
PHP Version5.0.4
OSlinux/fedoracore4
Roadmaps(Not assigned)

Comments

[2006-01-27 14:30 UTC] renzo dot toma at xs4all dot nl

Description:
------------
PHP Notice: Undefined index: TotalResults in /usr/share/pear/Services/Amazon.php on line 796

Can easilly be fixed with an:

if (isset($data['TotalResults'])) {
$totalresults = $data['TotalResults'];
} else {
$totalresults = '';
}

Did Amazon change the XML structure?

Test script:
---------------
#!/usr/bin/php
<?php

if ($argc != 2) {
print "Usage: $argv[0] <asin>\n";
die;

}

$asin = $argv[1];

require_once 'PEAR.php';
require_once 'Services/Amazon.php';

$amazon = &new Services_Amazon('...', 'dev');
$products = $amazon->searchAsin($asin);

if(!PEAR::isError($products)) {

if (isset($products[0])) {
$product = $products[0];
$authors = implode(', ', $product['authors']);

echo "{$product['name']}, {$authors}, {$product{'asin'}}, {$product['imagesmall']}, {$product['url']}";

}

} else {
echo $products->message;
}
?>

Expected result:
----------------
No PHP notice

Actual result:
--------------
PHP Notice: Undefined index: TotalResults in /usr/share/pear/Services/Amazon.php on line 796

[2006-01-27 16:53 UTC] ttsuruoka at php dot net

This bug has been fixed in CVS.

Thank you for reporting!