SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    U.S.
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php code having a problem

    Hi,
    I have used the div tag around the photos which are looping inside the div tag, but not sure which php codes are having a syntax problem, would you please give me a help? Much appreciate!

    Code:
    <div id="bilden">
     <?php do { ?>
          <div id="bild">
    	  <a class="scalp" href="#"><img src="../images/<?php echo $row_rst_artwork['photo']; ?>" width="115" border="0"/><b><img src="../images/<?php echo $row_rst_artwork['photo']; ?>" /></b></a>
    			<ul>
    			  <li><?php echo $row_rst_artwork['caption']; ?></li>
    			<li><?php echo $row_rst_artwork['date']; ?></li>
    			<li><?php echo $row_rst_artwork['type']; ?></li>
    		  </ul>
    	  </div>
    	  <?php $row_rst_artwork = mysql_fetch_assoc($rst_artwork); $row_loop++;} while ($row_rst_artwork && $row_loop < 4); $row_loop=0; ?> 
    <?php }  ?> 
    </div>

  2. #2
    SitePoint Zealot erikwebb's Avatar
    Join Date
    Dec 2003
    Location
    Atlanta, GA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you have an extra brace hiding in the line below the </div> tag. You have a brace at:
    PHP Code:
    $rowloop++;} 
    and then another one on the next line:
    PHP Code:
    <?php }  ?>
    My guess would be that you don't want that second line.

    HTH,
    Erik

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a suggestion about writing code and then finding those !#%@*! typos and syntax errors.

    You might think about a better structure to make your code more readable:

    PHP Code:
      <div id="bilden">
     <?php do { ?>
          <div id="bild">
          <a class="scalp" href="#"><img src="../images/<?php echo $row_rst_artwork['photo']; ?>" width="115" border="0"/><b><img src="../images/<?php echo $row_rst_artwork['photo']; ?>" /></b></a>
                <ul>
                  <li><?php echo $row_rst_artwork['caption']; ?></li>
                <li><?php echo $row_rst_artwork['date']; ?></li>
                <li><?php echo $row_rst_artwork['type']; ?></li>
              </ul>
          </div>
          <?php $row_rst_artwork mysql_fetch_assoc($rst_artwork);
                
    $row_loop++;
                }
                while (
    $row_rst_artwork && $row_loop 4);
                    
    $row_loop=0;
                    
    ?>
    <?php 
    }  ?>
    </div>
    When you do this, it makes finding that extra brace } much easier! It also shows that you didn't need to reinvoke php just to get that last brace in!

    Al


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •