473,659 Members | 3,239 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 1858
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($I D_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:1 5) in path_here/client.php on line 138
PNG  IHDR@ŁbK GD˙˙˙ ˝ pHYs  śtIME $ńIDATx ťůsG˛?}Ł KĚe{őFĽ ź6> ˇű}OUő~hF b&żĄşŞŞľ 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ŇX bČřŘ8mś<v wim˝~L, ŮcĹ1&&(N iŐ[TjˇŹid˛&Ć&p <VEuŻJ Ł C,"JaZ&n `0Đt@A*ťbbl l!kĺZ'oPŇ nVXşc:( M!ť~vŤřx)Ź f.͐e0-XTv+ńřŰ >ČXľu3ĎD p˛Ĺ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($I D_CLIENT); <--- returns image type

it tries to download it istead of displaying it

thank You
Mar 9 '08 #5
oll3i
679 Contributor
$image = imagecreatefrom string($data); doesnt work neither
Mar 9 '08 #6
hsriat
1,654 Recognized Expert Top Contributor
$image = imagecreatefrom string($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_arr ay(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

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

Similar topics

8
4409
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 image, which will upload the record to a mySql db so users can then either view all profiles or query.. I.e. show all males in UK, all femails over 35 etc. Now, I'm not asking for How to do this but more what would be the best way? I've looked at...
3
3636
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 have to set those properties to something - is there a way in php to get an image width and height so I can set it correctly for each image? <IMG SRC="<?php echo $php_image ?>" WIDTH="268" HEIGHT="176" BORDER="0" ALT="">
1
4804
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 from reading the documentation is how to use these image functions to operate on image data -- it looks like you get a GD image resource in each case by specifying a file name, not by passing image data directly. While I can see how that's...
5
12024
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
11753
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 table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
1650
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; command , but i'm not able to see the image back in F1. How do i retrieve the image in proper format??
2
9300
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 a db table. Please note, I am using a PostgreSQL database I have written all the code out below that deals with the submission processing:
6
2533
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 will them click the 'read more' link to view the entire article. It will also display a thumbnail of the article image. As the image is stored at its full display size in the DB I need to be able to resize it before outputing it.
10
7392
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 recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the data into the table, however, I get the following error when trying to view the image "the image ......
0
2121
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 is the 'blob' cfoto.seek(0) foto=cfoto.getvalue
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7356
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2752
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 we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.