Hey people,

Wonding if anyone can help me out with this:

echo '<td width="' . $colWidth . '%">' . 
		     '<a href="index.php?page=list-image&album=' . $row['al_id'] . '">' .
		     '<img src="'. ALBUM_IMG_DIR.$row['al_image'] . '" border="0">' . 
			 '<br>' . $row['al_name'] . '</a><br />' . $numImages . '</td>';

the error is to do with

<img src="'. ALBUM_IMG_DIR.$row['al_image'] . '" border="0">' . 

and with the defined constant ALBUM_IMG_DIR

Any thoughts anyone? Cheers in advance.

    What should happen?
    What is happening?
    How does the code look like in the browser?
    Does it work if you do a normal HTML page with the information?
    Does the different variables echo the correct string when you just echo them?

      You still need to address Piranha's questions for us to really know what the question/problem is; but in general I like to handle such outputs with printf(), just to keep things more organized and not have to worry about keeping all my concatenations and quotes correct:

      printf(
         '<td width="%s%%"><a href="index.php?page=list-image&album=%s">' .
         '<img src="%s%s" border="0"><br />%s</a><br />%s</td>',
         $colWidth,
         $row['al_id'],
         ALBUM_IMG_DIR,
         $row['al_image'],
         $row['al_name'],
         $numImages
      );
      

        Many thanks for your thoughts, and appologies for not being more specific.

        I attempted the printf method suggested but the same results appear.

        Basically, the constant ALBUM_IMG_DIR is a directory on the server and therefore when executed an image should be displayed based on this dir. I have used this constant elsewhere on different pages in the following way:

        <img src="<?php echo ALBUM_IMG_DIR.$row['al_image']; ?>" border="0">

        And this works perfectly where I avoid the html concatenation process.

        With this in mind I have also re-written the the code without the use of echoing html and I still get the same result - the image is simply not showing!

          Ok don't worry about it guys for this particular page I have just used the actualy directory in replace of the constant. Not ideal but at least it works. Thanks for your time.

            Showing us what ALBUM_IMB_DIR is might help - if it's an absolute path like /home/user/public_html/images/ then that's the problem - you have to use the path relative to your website's root folder (e.g. [url]http://yoursite.com)[/url].

            Either way, don't forget to mark this thread resolved (if it is).

              Write a Reply...