473,505 Members | 15,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image stored in mysql

oll3i
679 Contributor
I want to display image from mysql in php page
but i have headers already sent this is what it says
will i have to change the included headers file to display images form mysql?

thank You
Mar 9 '08 #1
13 1845
Markus
6,050 Recognized Expert Expert
Post your code and we'll tell you wherre you've gone wrong.
Mar 9 '08 #2
oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1. public function displayLogo($ID_CLIENT){
  2.  
  3.  
  4.     $result=mysql_query("SELECT logo,logo_type FROM ".$this->tables['clients']." WHERE ID_CLIENT='$ID_CLIENT'")or die ("SELECT ERROR:(table clients)".mysql_error());
  5.     $type = MYSQL_RESULT($result,0,"logo_type");
  6.     $data = MYSQL_RESULT($result,0,"logo");
  7.     header("Content-type: $type");
  8.  
  9.     echo $data;
  10.     }
  11.  
logo is blob

then on the site

<td>
<? echo $client->displayLogo($ID_CLIENT); ?>
</td>


but i get
Warning: Cannot modify header information - headers already sent by (output started at /home/aa24985/domains/purcon.pl/public_html/exec-jobs/config/vert_menu.php:15) in path_here/client.php on line 138
PNG  IHDR@ŁbKGD˙˙˙ ˝ pHYs  śtIME $ńIDATxťůsG˛?}ŁKĚe{őFĽź 6> ˇű}OUő~hFb&żĄşŞŞľYY9RJ ż1d $$H !A $HH AB $H A $$H !A˙0ĎH!J˘BCCi S7J˘Łh`Xi˘/;ԞqBĚԑHĐŔL4]Ă4͑gG CTH%ŃĐvC3źaż="BĽěĐŹăą ~č#p0$ #"Ĺs˛,LŰMąeZo5)$ˇ@ŤHJtMǶmܴgčĆ e`!ąTń\ęeYzţđřD$PęĐhńčahş&AŮV1ě ٢^Żl&Ť7Čć˛ččQ%ť~(ŚČĺsŚOŚS*0ş Tv+[uęőz<J`&ąLŇXbČřŘ8mś<vwim˝~L, ŮcĹ1&&(NiŐ[TjˇŹid˛&Ć&p<VEuŻJŁ C,"JaZ&n `0Đt@A*ťbbll!kĺZ'oPŇnVXşc:(M!ť ~vŤřx)Ź f.͐e0-XTv+ńřŰ >ČXľu3ĎDp˛Ĺp8^Żď

etc
Mar 9 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
Similar question was asked earlier by someone. Have a look at this.
Mar 9 '08 #4
oll3i
679 Contributor
but when i add header("Content-type: $type; charset=windows-1250");
where the type is
$type=$client->getLogoType($ID_CLIENT); <--- returns image type

it tries to download it istead of displaying it

thank You
Mar 9 '08 #5
oll3i
679 Contributor
$image = imagecreatefromstring($data); doesnt work neither
Mar 9 '08 #6
hsriat
1,654 Recognized Expert Top Contributor
$image = imagecreatefromstring($data); doesnt work neither
You have to make a new PHP file for displaying images.

In that PHP file, give header of image type and print all the image data afterwards.[php]<?php
//filename: image.php
if ($_GET['img']=="")
die ('Invalid Parameter');
header("Content-type:image/jpeg");//whatever is the extension
$data = mysql_fetch_array(mysql_query("SELECT `image` FROM ...... WHERE `id`='".$_GET['img']."'"));
print($data['image']);
?>[/php]And in your HTML file, where you need to display that image, write[HTML]<img src="image.php?img=abc" alt="abc" />[/HTML]
Mar 10 '08 #7
oll3i
679 Contributor
i have
Expand|Select|Wrap|Line Numbers
  1. <?
  2. include('../config/config.php');
  3. $config = new config();
  4. $config->mysql_server_connect();
  5.  
  6. $result=mysql_query("SELECT logo_name,logo_size,logo_type,logo FROM ".$config->tables['clients']." WHERE ID_CLIENT=$ID_CLIENT") or die("SELECT Error(table clients): ".mysql_error());
  7.  
  8. list($name, $type, $size, $data) = mysql_fetch_array($result);
  9.  
  10. header("Content-length: $size");
  11. header("Content-type: $type");
  12. header("Content-Disposition: attachment; filename=$name");
  13. echo $data;
  14.  
  15. ?
  16.  
but how do i now pass that id_client to that file and display the image
Mar 10 '08 #8
oll3i
679 Contributor
sorry i didnt notice that you actually wrote it :)
Mar 10 '08 #9
oll3i
679 Contributor
but still i get X instead of logo
Mar 10 '08 #10
hsriat
1,654 Recognized Expert Top Contributor
but still i get X instead of logo
Right click on the X thingy, and click on view image.
You may see what's the error.
Mar 10 '08 #11
oll3i
679 Contributor
it doesnt display the error but i know it passes the right id_client
Mar 10 '08 #12
oll3i
679 Contributor
maybe there is something wrong in my download.php file
Expand|Select|Wrap|Line Numbers
  1. include('../config/config.php');
  2. $config = new config();
  3. $config->mysql_server_connect();
  4.  
  5. $result=mysql_query("SELECT logo_name,logo_size,logo_type,logo FROM ".$config->tables['clients']." WHERE ID_CLIENT='$ID_CLIENT'") or die("SELECT Error(table clients): ".mysql_error());
  6.  
  7. list($name, $size, $type,  $data) = mysql_fetch_array($result);
  8.  
  9.  
  10. header("Content-length: $size");
  11. header("Content-type: $type");
  12. header("Content-Disposition: attachment; filename=$name");
  13.  
  14. echo $data;
  15.  
Mar 10 '08 #13
oll3i
679 Contributor
okey it works now :) i had mistake in the path to config class
thank You a lot for Your help
Mar 10 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4396
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
3
3625
by: Ralph Freshour | last post by:
My .php app displays an image on the web page, I notice that different ..jpg images display "funny" - apparently they all have slightly different image widths and heights yet in the image tag I...
1
4791
by: Weston C | last post by:
I'm new to the GD/Image functions with PHP, and I'm trying to use them to manipulate jpeg images that I've stored in a MySQL database (specifically, creating thumbnails). The thing I can't tell...
5
12008
by: Alper Adatoz | last post by:
Hi, i have a little problem. i hope u guys give me a clear solution (: db: mssql i just want to put jpeg file to the image field at the mssql db. and after that i want to call it back..
3
11737
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
1643
by: Sreesekhar Palaparthy | last post by:
I used mysql_real_escape_string() method to insert image file into database. Now how do icheck whether it got stored in proper format ?? I used SELECT * INTO OUTFILE F1 FROM IMGTABLE; ...
2
9275
by: bissatch | last post by:
Hi, I am trying to write script that is run when a form is submitted. The form contains an image input field and when submitted, the image is uploaded, resized and added as binary information to...
6
2519
by: bissatch | last post by:
Hi, I have a collection of images stored in a DB. They are there for the purpose of a news system. When the user views the homepage it will diplay cropped versions of the news where the user...
10
7378
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
0
2095
by: dimitri pater | last post by:
Hi, I am trying to insert an image, which is stored as a blob in MySQL, into a table using Reportlab. I have tried this: from StringIO import StringIO cfoto = StringIO(result) # where result...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.