简体   繁体   中英

php not executing another script

I have a.php file that looks like this:

foreach($stmt->fetchAll() as $array)
              {
            echo '<div class="thumb" style="width: '.$array['thumb_width'].'px; height: '.$array['thumb_height'].'px;">
            <p><a href="showfile.php?image_id='.$array['image_id'].'">
            <img src="showthumbs.php?image_id='.$array['image_id'].'" alt="'.$array['image_name'].' /">
            </a></p>
            <p>'.$array['image_name'].'</p></div>';
            }

I am following the tutorial here to basically upload and show images. When I view source the page that is loaded ( which you can test out here ), for some reason it's not displaying the image. I have the showthumbs.php on the same location as the location of the gallery.php. What am I missing?

The problem is with your showthumbs.php. You need to tell the browser that the page returns an image. Right now, it is trying to take the image data and parse it as if it were text.

To do so, add the following line to showthumbs.php (before you output the image):

header("Content-type: image/jpg");

i'm pretty sure this is related...

on your page: (the one you're trying to use as the image) http://renps.nm3.co/showthumbs.php?image_id=1

you got an echo or something that says OH MY GOD and create an error...

Warning: Cannot modify header information - headers already sent by (output started at /home/renps/public_html/showthumbs.php:2) in /home/renps/public_html/showthumbs.php on line 41

You probalby have a line break before your <?php tag. That means something has already been output to the response body when you try to set the header. And Headers must be set before the Body is sent. Otherwise you get the error:

Warning: Cannot modify header information - headers already sent

Just look for any chars before <?php in showthumbs.php. My guess is it's a space or new line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM