Please help me with an error in php

+1 Vladimir Feschenko · August 22, 2015

https://www.youtube.com/watch?v=kVPrEI-4meg
PHP Instagram Downloader Tutorial - 9 - Printing Users Images

After watching this video tutorial, I did everything as well as the author. But at that moment, when I go to the page index.php, I wrote the following error:

Notice: Undefined index: data in /home/windjobs/public_html/index.php on line 49
Warning: Invalid argument supplied for foreach() in /home/windjobs/public_html/index.php on line 49

That's part of my script:
 foreach($results['data'] as $items){
$image_url = $items['images']['low_resolution']['url'];
echo '<img src=" ' . $image_url . ' " /> <br/>';
savePicture($image_url);
}

Images from Instagram.com not downloaded or saved. What can be the problem? For the author it worked. The server is 5.4.36 version of php.

Post a Reply

Replies

Oldest  Newest  Rating
0 Marco Schindler · August 28, 2015
Hello Vladimir,

it seems the $result array you are providing does not have an index called 'data'.

Try to use
var_dump($results['data']);

to print out your result array.

Maybe there was an error fetching the results and you didn't notice until now.
  • 1

PHP

107,287 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators