ob_start() -- ob_end_flush() problem

From: Date: Thu, 27 Apr 2017 15:00:34 +0000
Subject: ob_start() -- ob_end_flush() problem
Groups: php.general 
Request: Send a blank email to php-general+get-326073@lists.php.net to get a copy of this message
Hi guys: As many of you know, I teach PHP at my local college. I’ve run into a problem and I can’t find a reason/solution. Here’s the situation — I use ob_start() -- ob_end_flush() (see below) and my code works. However, when my students try it, even using my code, it doesn’t work for them. Now, both my students and I are on the same server with supposedly the same settings — what could go wrong? What should we look for? Many thanks in advance for those providing their time/expertise to help. Thank you, tedd — here’s the code: <?php /* display-db-image.php // this script gets an image from an image-field in a db table // and displays the image "as-is" /* start buffered output */ ob_start(); $table = 'image_table'; $id = isset($_GET['id']) ? $_GET['id'] : 1; if(!ctype_digit($id)) // clean -- make sure the $id is a number { $id = 1; } include('includes/open-db.php'); //====== open dB $query = "SELECT image FROM $table WHERE id = '$id' "; $result = mysqli_query($conn, $query) or die("$query Could not get image"); include('includes/close-db.php'); //====== close dB if(mysqli_num_rows($result) == 1) { $row = mysqli_fetch_assoc($result); $image = $row['image']; // set the header for the image header("Content-type: image/jpeg"); echo($image); } $page = ob_get_contents(); /* end buffered output */ echo($page); ob_end_flush(); ?> — end of code _______________ tedd sperling tedd@sperling.com

« previous php.general (#326073) next »