Displays blob images in the database.

Source: Internet
Author: User
Show blob images in the database. my images cannot show showimage. php.
 query($sql );$query_num = $SqlHelper->num_rows ($query );$rows = array ();  $retarr = array (); $query =$SqlHelper->query ( $sql );if($query){$arr_teainfo2 = array ();while ( $arr_teainfo = $SqlHelper->fetch_assoc($query) ) {$arr_teainfo2 [] = $arr_teainfo;$Id=$arr_teainfo["Id"];echo $arr_teainfo["Id"];echo ""; }}?>  


Second. php3
 query($sql );$query_num = $SqlHelper->num_rows ($query );$rows = array ();  $retarr = array (); $query =$SqlHelper->query ( $sql );if($query){$arr_teainfo2 = array ();while ( $arr_teainfo = $SqlHelper->fetch_assoc($query) ) {$arr_teainfo2 [] = $arr_teainfo;$Id=$arr_teainfo["Id"];$imagetype=$arr_teainfo["imagetype"];//echo $arr_teainfo["images"];//Header( "Content-type: $imagetype"); header('Content-type: $imagetype');echo $arr_teainfo["images"];}}?>   


What is my problem? New PHP guy, I don't know what's wrong


Reply to discussion (solution)

1. can your php3 files be correctly parsed? Check the configuration file.
2. if the program file is UTF-8 encoded, make sure that there is no BOM header.
3. do not use loops for output images of Second. php3.

1. can your php3 files be correctly parsed? Check the configuration file.
2. if the program file is UTF-8 encoded, make sure that there is no BOM header.
3. do not use loops for output images of Second. php3.
I added AddType application/x-httpd-php. php. html. htm. php3 to the httpd. conf file.
Is it possible to parse php3 files normally?

1. can your php3 files be correctly parsed? Check the configuration file.
2. if the program file is UTF-8 encoded, make sure that there is no BOM header.
3. do not use loops for output images of Second. php3.
My program file is gbk

I tested it. php3 can be parsed normally, but it still doesn't work. who can help?

The picture cannot be displayed. Is it a program error? Or the path is incorrect.
Print it first to see if there is any data. If yes, check whether the displayed path is correct.

The picture cannot be displayed. Is it a program error? Or the path is incorrect.
Print it first to see if there is any data. If yes, check whether the displayed path is correct.
Run php3 to print the image. it is normal and no error is reported.

 query($sql );$query_num = $SqlHelper->num_rows ($query );$rows = array ();  $retarr = array (); $query =$SqlHelper->query ( $sql );if($query){$arr_teainfo2 = array ();while ( $arr_teainfo = $SqlHelper->fetch_assoc($query) ) {$arr_teainfo2 [] = $arr_teainfo;$Id=$arr_teainfo["Id"];$imagetype=$arr_teainfo["imagetype"];$image= $arr_teainfo["images"];}//header('Content-type: image/jpeg ');echo $image; }

The above code has been posted many times.

Not in my program


The picture cannot be displayed. Is it a program error? Or the path is incorrect.
Print it first to see if there is any data. If yes, check whether the displayed path is correct.
Run php3 to print the image. it is normal and no error is reported.

 query($sql );$query_num = $SqlHelper->num_rows ($query );$rows = array ();  $retarr = array (); $query =$SqlHelper->query ( $sql );if($query){$arr_teainfo2 = array ();while ( $arr_teainfo = $SqlHelper->fetch_assoc($query) ) {$arr_teainfo2 [] = $arr_teainfo;$Id=$arr_teainfo["Id"];$imagetype=$arr_teainfo["imagetype"];$image= $arr_teainfo["images"];}//header('Content-type: image/jpeg ');echo $image; }

The program did not report an error. I copied the output data to the address bar. Is there any picture displayed ??



The picture cannot be displayed. Is it a program error? Or the path is incorrect.
Print it first to see if there is any data. If yes, check whether the displayed path is correct.
Run php3 to print the image. it is normal and no error is reported.

 query($sql );$query_num = $SqlHelper->num_rows ($query );$rows = array ();  $retarr = array (); $query =$SqlHelper->query ( $sql );if($query){$arr_teainfo2 = array ();while ( $arr_teainfo = $SqlHelper->fetch_assoc($query) ) {$arr_teainfo2 [] = $arr_teainfo;$Id=$arr_teainfo["Id"];$imagetype=$arr_teainfo["imagetype"];$image= $arr_teainfo["images"];}//header('Content-type: image/jpeg ');echo $image; }

The program did not report an error. I copied the output data to the address bar. Is there any picture displayed ??
This is not the image address, but the blob data type.

Http: // localhost/Second. php3? Id = 10
What can I do?

Http: // localhost/Second. php3? Id = 10
What can I do?
If there is a header ('content-type: image/jpeg ');, it is an image that shows forks, that is, it cannot be displayed. if it is commented out, it is executed echo $ image ;, A lot of unreadable characters are displayed, because they are blob-type and cannot be output normally.

Http: // localhost/Second. php3? Id = 10
What can I do?
The image with the id 10 I tested is jpg, so I first write a fixed header ('content-type: image/jpeg ');

A bunch of mess? It doesn't matter. cut a graph.

Capture images and cards for half a day

There are many more

A bunch of mess? It doesn't matter. can I understand a screenshot? it's messy and I don't know anything.

Your image format is incorrect!

In this case, you write $ image to a file, such as file_put_contents('test.jpg ', $ image );
Then, send him up.

 

My original version code.
It's pjpeg.

Your image format is incorrect!

In this case, you write $ image to a file, such as file_put_contents('test.jpg ', $ image );
Then, send him up.
I have a holiday a few days ago. I asked for leave yesterday. I will upload it later.

Your image format is incorrect!

In this case, you write $ image to a file, such as file_put_contents('test.jpg ', $ image );
Then, send him up.
Can be written normally

Test.jpg is another image. after writing, it is the image.

 

My original version code.
It's pjpeg.
I still cannot display it using pjpeg. I use gbk format. what format do you use?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.