biggupp Posted April 18, 2012 Share Posted April 18, 2012 http://ahy4life.com/test2/press.php I am following the tutorial below: http://www.adambate.com/how-to-add-a-flickr-based-photo-gallery-to-your-website-phpflickr-lightbox/ I am encountering errors when I introduce the code below. Not sure what is causing it. The flickr photo set is named 'AHY' . php and js <CODE> <script type="text/javascript" src="photos/lightbox2.05/js/prototype.js"></script> <script type="text/javascript" src="photos/lightbox2.05/js/scriptaculous.js?load=effects,builder"></ script> <script type="text/javascript" src="photos/lightbox2.05/js/lightbox.js"></script> <?php require_once("photos/phpFlickr-3.1/phpFlickr.php"); $f = new phpFlickr("b16911dd0ec59f16ed66e80711edbdaf"); // API $user = "[email protected]"; $ph_sets = $f->photosets_getList($user); ?> </CODE> <CODE> <!-- Photo Gallery --> <div id="gallery"> <?php foreach ($ph_sets['AHY'] as $ph_set): ?> <div class="photosets"> <p><h2><?php print $ph_set['title']; ?></h2></p> <?php $photoset_id = $ph_set['id']; $photos = $f->photosets_getPhotos($photoset_id); foreach ($photos['AHY']['photo'] as $photo): ?> <div class="photos"> <a rel="lightbox[]" href="<?= $f->buildPhotoURL($photo, 'medium') ?>" title="<?= $photo['title'] ?>"> <img src="<?= $f->buildPhotoURL($photo, 'square') ?>" alt="<?= $photo['title'] ?>" title="<?= $photo['title'] ?>" /> </a> </div> <?php endforeach; ?> </div> <?php endforeach; ?> </div> The CSS I use for this is: #gallery { position: relative; float: left; width: 600px; padding: 0px 15px 10px 15px; } .photos { position: relative; float: left; display: block; padding-bottom: 10px; } .photosets { clear: both; padding-top: 1px; } .photosets h2 { color: #000; } </CODE> Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/ Share on other sites More sharing options...
Muddy_Funster Posted April 19, 2012 Share Posted April 19, 2012 please post code inside code tags, and for the love of whichever celestial being you happen to worship, post what the actual error is! Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1338677 Share on other sites More sharing options...
biggupp Posted April 19, 2012 Author Share Posted April 19, 2012 This is the error: Warning: Invalid argument supplied for foreach() in /home1/ahyfouli/public_html/test2/press.php on line 359 The CSS I use for this is: #gallery { position: relative; float: left; width: 600px; padding: 0px 15px 10px 15px; } .photos { position: relative; float: left; display: block; padding-bottom: 10px; } .photosets { clear: both; padding-top: 1px; } .photosets h2 { color: #000; } Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1338711 Share on other sites More sharing options...
Muddy_Funster Posted April 19, 2012 Share Posted April 19, 2012 so this is the problem : <?php foreach ($ph_sets['AHY'] as $ph_set): ?> To the best of my knowledge you can't call a specific array key in a for each, only the array variable it's self: <?php foreach ($ph_sets as $ph_set): ?> Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1338731 Share on other sites More sharing options...
biggupp Posted April 19, 2012 Author Share Posted April 19, 2012 Hmmm...Thanks. How then might I call a specific flickr 'set' ? Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1338749 Share on other sites More sharing options...
Muddy_Funster Posted April 19, 2012 Share Posted April 19, 2012 you could try nesting another for each inside it: foreach ($ph_sets as $ph_set){ if ($ph_set == 'AHY'){ foreach($ph_set as $set_ahy){ //change all the refferences from $ph_set to $set_ahy Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1338794 Share on other sites More sharing options...
adambate Posted May 24, 2012 Share Posted May 24, 2012 The issue is with the following line: <?php foreach ($ph_sets['AHY'] as $ph_set): ?> It should be: <?php foreach ($ph_sets['photoset'] as $ph_set): ?> The 'photoset' in this particular case is part of the API and not to be replaced with your photoset ID. I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/261207-how-to-embed-a-photo-gallery-from-picasa-flickr-etc/#findComment-1348177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.