1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
if($id)
{
//please change the server name username and password according to your mysql server setting
$mysql_server="loaclhost";
$mysql_username="root";
$mysql_password="dbpass20";
$mysql_database="rnr";
//connect to database using above settings
@MYSQL_CONNECT("localhost",$mysql_username,$mysql_password);
@mysql_select_db("rnr");
//select the picture using the id
$query = "select bin_data,filetype from ads where id=$id";
//execute the query
$result = @MYSQL_QUERY($query);
//get the picture data which will be binary
$data = @MYSQL_RESULT($result,0,"bin_data");
//get the picture type. It will change according to file extension it may be either gif or jpg
$type = @MYSQL_RESULT($result,0,"filetype");
//send the header of the picture we are going to send
Header( "Content-type: $type");
//send the binary data
echo $data;
};
?> |
Partager