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
2010-09-18 14:43:16
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
2010-09-19 10:28:26
That's exactly what this script is for. You need to load your blob into a variable and use `MemImage($blob, ...)` method
Mchl
2010-09-19 11:06:11
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
2010-09-19 12:43:02
//Load an image into a variable$logo = file_get_contents('logo.jpg');//Output it$pdf->MemImage($logo, 50, 30);
John Tan
2010-09-19 12:44:01
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
2010-09-19 12:46:02
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
2010-09-20 14:39:54
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
2010-09-20 14:41:43
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
2010-09-20 14:44:05
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
2010-09-20 14:45:13
Can you guide me on this please.
John Tan
2010-09-20 14:55:01
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
2010-09-20 15:42:09
ok sir, thank you very much.... cheers
John Tan
2010-09-20 16:35:10