Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code I have used to test it. The code I have written after your suggestion is as follows.
header('Content-Type: image/jpeg');
The above code is yielding me a picture. Now, When I tried to use it in my original code it is not giving me the image. Instead it is giving me this warning *Warning*: Cannot modify header information - headers already sent by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php* on line *221* and a lot binary characters again instead of the image. I know something about this warning that we should not output anything to the browser before the header. But I cannot do that, since I need the user input using a html form and I use the input to fetch the data and dispaly it in a table along with the image. I am posting the whole code below. Please do let me know about any changes, corrections or modifications that are needed. The image display code is towards the last.


<form action="mysqli.php" method="post">
<div align="center">
Building Name:<select name="name">
<option value=""> Select a Building</option>
     <option value="Williams Hall">Williams Hall</option>
     <option value="Women's Softball Field">Women's Softball Field</option>
     <option value="Wright House">Wright House</option>
                   <input type="submit" />
// Connects to your Database
$cxn=mysqli_connect($host, $user, $password, $dbname) ;
if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
       echo "$error";
       echo "Connection established successfully";
//Define the variables for Day and Month
if ($minute>=00 && $minute<=14)
elseif ($minute>=15 && $minute<=29)
elseif ($minute>=30 && $minute<=44)
$sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy2, Image where (buildings.buildingcode=occupancy2.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy2.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='Monday' AND Time='$times'";
$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
       echo "$error";
       echo "<br>";
       echo "Query sent successfully";
echo "<br>";
echo "<table border='1' cellspacing='5' cellpadding='2'>";
echo "<tr>\n
       <th>Parking Lot</th>\n
       <th>Estimated Number of Empty Spaces</th>\n
       <th>Distance (Feet)</th>\n
       <th>Estimated walking time to the building</th>\n
while ($row=mysqli_fetch_array($data))
$building = $row[0];
     $parking_lot = $row[1];
     $Number_of_Empty_Spaces = $row[2];
     $Distance = $row[3];
     $time_l = $row[4];
$location=$row[6]; echo "<tr>\n
<td>$parking_lot</td>\n <td>$Number_of_Empty_Spaces</td>\n
             <td>$time_h - $time_l mins</td>\n
   echo "</table>\n";
header('Content-Type: image/jpeg');
Nathan Nobbe wrote:
On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram <sashi...@vt.edu> wrote:

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');

Which you have suggested. This is the piece of code which is returning all
the binary character stuff. The code is definitely fetching the image. But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary. Is
there any way we can convert the binary content to jpeg/jpg content again.
This is my guess after having gone through the code again.

i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such as

so, then i tossed this together,


header('Content-Type: image/jpeg');


Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to