[PHP] ob_start() -- ob_end_flush() problem
- Date: Thu, 27 Apr 2017 11:00:34 -0400
- From: Tedd Sperling <tedd@xxxxxxxxxxxx>
- Subject: [PHP] ob_start() -- ob_end_flush() problem
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.
— 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 */
$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
$page = ob_get_contents();
/* end buffered output */
— end of code
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php