Search
Left Quote    Wise men speak because they have something to say; Fools because they have to say something.
- Plato (427-347 B.C.)    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Why doesn't this work?
  This user is offline  lingh0e
  Subject: "Why doesn't this work?" Posted: @ 4:32 am on Apr 21 2007   

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

Trying to display a directory of images.


Code:
<?php
Header( "Content-t ype: image/jpeg" ;);
$dir1 = ("./images /thumbs/ads/&qu ot;);
$dir = opendir("$ dir1");
while ( ($file=readdir( $dir)) !== false ) {
echo '<img src=' . $dir1 . $file . ' /><br />' . "\n";
}
closedir($dir);
?>



This gives me a blank page, but when I view the source it gives valid sources, complete with file names.

Where am I going wrong?


Feel free to kick me if I get annoying
    Viewed: 10,559 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Why doesn't this work?" Posted: @ 6:06 am on Apr 21 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Do you need to set the header as an image to display an set of images? Try removing that line... All of the rest of the code seems pretty straight forward. In your $dir1 variable, try using the absolute path: $dir = $_SERVER['docu ment_root'] . "/images/ thumbs/ads/&qu ot;);




-bs0d | AllSyntax.com

    Viewed: 10,551 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: Why doesn't this work?" Posted: @ 4:18 pm on Apr 24 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

  bs0d said...

< i> Do you need to set the header as an image to display an set of images? Try removing that line... All of the rest of the code seems pretty straight forward. In your $dir1 variable, try using the absolute path: $dir = $_SERVER['docu ment_root'] . "/images/ thumbs/ads/&qu ot;

I've tried the absolute path, but it gives me the same result. It's not having a problem finding the files, when I view the source for the page it has the img tags complete with the file names. It just doesn't display them.




Feel free to kick me if I get annoying

    Viewed: 10,523 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: Why doesn't this work?" Posted: @ 7:16 pm on Apr 25 2007    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

did you get rid of the content-type header? php's default text/html is correct for the output of this script.

you could also try dropping the ./ at the beginning of $dir1




please note that the above post is likely made up in its entirety.

    Viewed: 10,513 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: Why doesn't this work?" Posted: @ 5:58 am on Apr 28 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

I ended up retyping all the code in a whole new page. I don't really know what I did, but it works now.

Awsome!




Feel free to kick me if I get annoying

    Viewed: 10,486 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank