foucquet Posted October 23, 2012 Share Posted October 23, 2012 I am trying to bring a flickr feed into a webpage, and can't work out why this:- <?php // >>> Set up the variables needed <<< $photos = array(); $encode_params = array(); $maximgs = 19; // >>> This need to be 1 less than actual req'd No. as array counts from 0 <<< // >>> Set up the parameters for the API <<< $api_params = array( 'api_key' => 'my api key', 'method' => 'flickr.photos.search', 'user_id' => 'my id', 'format' => 'php_serial', ); //>>> Encode the parameters ready to make API request <<< foreach($api_params as $k => $v){ $encode_params[] = urlencode($k) . '=' . urlencode($v); } var_dump($encode_params); // >>> Construct API url and make the request <<< $api_url = 'http://api.flickr.com/services/rest/?' . implode('&', $encode_params); var_dump($api_url); // >>> Retrieve images <<< $rsp = file_get_contents($api_url); $rsp_obj = unserialize($rsp); echo $rsp_obj; var-dump($rsp_obj['photos']['photo']); //>>> Line 37 <<< ?> gives me "Parse error: syntax error, unexpected T_VAR in C:\wamp\www\php\flickr tests\prev3~.php on line 37". Link to comment https://forums.phpfreaks.com/topic/269823-unexpected-t_var/ Share on other sites More sharing options...
Jessica Posted October 23, 2012 Share Posted October 23, 2012 Really? you don't see anything wrong with "var-dump" ?? Link to comment https://forums.phpfreaks.com/topic/269823-unexpected-t_var/#findComment-1387242 Share on other sites More sharing options...
Psycho Posted October 23, 2012 Share Posted October 23, 2012 $api_params = array( 'api_key' => '1b6e67959f14d79c2c9c568b02c23f23', 'method' => 'flickr.photos.search', 'user_id' => '49466419@N05', 'format' => 'php_serial', ); Also, there is a comma after the last element - indicating that there should be another element in the array. Link to comment https://forums.phpfreaks.com/topic/269823-unexpected-t_var/#findComment-1387245 Share on other sites More sharing options...
ManiacDan Posted October 23, 2012 Share Posted October 23, 2012 Commas at the ends of the array declaration are valid, oddly enough. There are two places in PHP where errant commas are valid: 1) Trailing commas in array declarations: $a = array( 1,2,3, ); 2) Initial commas within list(): list(,$a) = explode(",", $Foo); Link to comment https://forums.phpfreaks.com/topic/269823-unexpected-t_var/#findComment-1387250 Share on other sites More sharing options...
foucquet Posted October 23, 2012 Author Share Posted October 23, 2012 OK, OK, I'm a complete dummy - didn't even spot those errors, too busy looking for everything but the bleedin' obvious! That indeed now works (hides head in shame!) Link to comment https://forums.phpfreaks.com/topic/269823-unexpected-t_var/#findComment-1387254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.