0

im getting a syntax error on this line of code and don't know the correct formatting for it.

This is the part i'm having problems with -

echo " 
   <ul>";  

foreach($photos as $photo) {  

           $farm              = $photo['farm'];  
           $server            = $photo['server'];  
           $photo_id          = $photo['id'];  
           $secret            = $photo['secret'];  
           $photo_title       = $photo['title'];  

<li><img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_t.jpg" alt="'.$photo['title'].'" ></li>  

The problem is with that li tag. How can i format it properly?

4
  • 1
    have you forgotten to place the echo in last line? Commented Apr 29, 2011 at 16:10
  • You also need to close your foreach loop Commented Apr 29, 2011 at 16:11
  • and to close the foreach brace. Unless your loop is longer than you have copy/pasted Commented Apr 29, 2011 at 16:12
  • 1
    What's the point of assigning variables if you aren't going to use them? Commented Apr 29, 2011 at 16:15

2 Answers 2

2

Per the comments, you probably mean to have the following for your last line:

echo '<li><img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_t.jpg" alt="'.$photo['title'].'" ></li>';
Sign up to request clarification or add additional context in comments.

3 Comments

Also, don't forget to close the foreach loop } (this might be in OP's code, but omitted for brevity sake)
@William, I didn't want to make any assumptions as the OP only mentioned the line in question.
Thanks for that guys. cheers William for pointing out i needed to close my loop :)
2

The <li> part should be quoted. Try:

echo " 
   <ul>";  

foreach($photos as $photo) {  

           $farm              = $photo['farm'];  
           $server            = $photo['server'];  
           $photo_id          = $photo['id'];  
           $secret            = $photo['secret'];  
           $photo_title       = $photo['title'];  

    echo '<li><img src="http://farm' . $photo['farm'] . 'static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_t.jpg" alt="' . $photo['title'] . '" ></li>';
}
echo '</ul>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.