views:

50

answers:

1

A have image save in mysql database as bolb and I wish to display it out in fpdf using php. I'm having problem doing this as I am very new to fpdf. I really need help. Thank you.

+1  A: 

You will need this extension to FPDF: http://www.fpdf.org/en/script/script45.php

[updated]

$query = "SELECT imageField FROM yyy WHERE ...";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$image = $row['imageField'];

$pdf->MemImage($image, 50, 30);
Mchl
Thank you for the reply, I have tried that, but i believe that only works if the image is saved into host. but my current image are saved in mysql (blob).
John Tan
That's exactly what this script is for. You need to load your blob into a variable and use `MemImage($blob, ...)` method
Mchl
I'm sorry but I still do not really understand and would like to have your guidedence... Refer to you earlier use of extension. I have copr the example...
John Tan
//Load an image into a variable$logo = file_get_contents('logo.jpg');//Output it$pdf->MemImage($logo, 50, 30);
John Tan
My image is stored in mysql data base where my database name is xxx and table is yyy and image as bolb. So may I know how can I call out the image.. your example is "logo.jpg". but I don think I can use that right?? Thank you
John Tan
Thank you for the good reply Mchl, but I'm sorry to say that I have a new error message: Fatal error: Call to undefined method PDF::MemImage() in /home/content/x/y/z/nettwork/html/magnit/view_pdf.php on line 113
John Tan
If I may tell you more, my tabe is set as CREATE TABLE `upload_photo_table` ( `id` int(11) NOT NULL auto_increment, `can_id` int(11) default NULL, `name` varchar(50) default NULL, `type` varchar(30) default NULL, `size` int(11) default NULL, `content` mediumblob, `upload_date` char(30) default NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
John Tan
And I have wriiten as you guidence as : $sql = "SELECT * FROM upload_photo_table WHERE can_id = $char";$result = mysqli_query($cxn,$sql) or die("Invalid query: ");$row = mysqli_fetch_assoc($result);$image = $row2['content'];$pdf->MemImage($image, 50, 30);
John Tan
Did you add the `VariableStream` class to your code, and extend the FPDF with the code from the link above? Looks like you didn't.
Mchl
Can you guide me on this please.
John Tan
Everything is explaied in the link above. If you have trouble with it, I'd suggest asking for help in FPDF forums. There's usually someone hanging around, and It's a lot more comfortable for such conversations than StackOverflow's Q-A system.
Mchl
ok sir, thank you very much.... cheers
John Tan