fj1200 Posted December 1, 2008 Share Posted December 1, 2008 Just 'discovered' what PEAR is all about and really want to use it, but having trouble incorporating it into any web pages. If I run <?php require_once("Image/Barcode.php"); $bc = new Image_Barcode; $bc->draw($_GET['NUM'], $_GET['TYP'], $_GET['IMG']); ?> It works perfectly and I get an image. If I try to imcorporate that into a web page I get: Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\barcode.php:2) in C:\wamp\php\PEAR\Image\Barcode.php on line 104 ‰PNG ??? IHDR???P???2???ñãο???PLTE???ÿÿÿ¥ÙŸÝ???2IDATxœc(q Œw-qeeyæ8?3o¤Ã™ó£á̸çp&ßmateó.¡??f/ÅÚŽM?????IEND®B`‚ I've looked up these errors, tried a few things but can't see a problem. And - yes, I've had a hunt around this very forum too and yes - read the Headers thread at the top of this forum. Still can't see it. I've tried image_barcode::draw and get the same problem. Can anyone suggest a solution? One of the issues is white space - that all looks ok unless I'm looking in the wrong place. Everything works a treat except this. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 How do you incorporate it into webpage? Quote Link to comment Share on other sites More sharing options...
fj1200 Posted December 1, 2008 Author Share Posted December 1, 2008 I've tried a few things: Adding it in directly to the top of the page as per the 1st code snippet print ("<img src=\"barcode2.php&NUM='$_Shortcode'&TYP='code39'&IMG='PNG'\">"); (this just produces an image placeholder) Image_Barcode::draw( ... ) Various things. I even got into trouble with wifey on Saturday night for playing with it when I'm NOT supposed to be working! I can't do anything about the header being sent from the PEAR module - and I'm not that good at ph anyway. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 print ("<img src=\"barcode2.php&NUM='$_Shortcode'&TYP='code39'&IMG='PNG'\">"); That should be the proper way to do it. Did you look at the generated source code to see if it was all right? See if you can embed it this way into plain HTML file. Quote Link to comment Share on other sites More sharing options...
fj1200 Posted December 1, 2008 Author Share Posted December 1, 2008 Don't mean to be thick but I've got to have something wrong somewhere. None of this works... Ths barcode2.php file that calls the PEAR ext. works fine - http://<servername>/barcode2.php?NUM=9780131471498&TYP=code39&IMG=png <?php require_once"C:\wamp\php\PEAR\Image\Barcode.php"; $bc = new Image_Barcode; $bc->draw($_GET[NUM], $_GET[TYP], $_GET[img]); ?> However if I try to then call that from the code below I just get an image placeholder. <html> <?php $Shortcode = "12345"; print ("<img src=\"barcode.php?NUM=9780131471498&TYP=code39&IMG=png\">"); ?> </html> <html> <img src="barcode2.php?NUM=123&TYP=code39&IMG=png"> </html> Tried with quotes, without quotes, haven't tried it backwards yet though.... If I can nail this one then the next one I want to try is the graphing one, then the data grid. These are 3 I've been looking for for ages and will make a real difference to me. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Try like that <html> <head> </head> <body> <img src="barcode2.php?NUM=123&TYP=code39&IMG=png"> <img src="http://<servername>/barcode2.php?NUM=123&TYP=code39&IMG=png"> </body> </html> Quote Link to comment Share on other sites More sharing options...
fj1200 Posted December 1, 2008 Author Share Posted December 1, 2008 Yup - that's got ot. Also changed the way I generate the barcode ; I'm now using <?php require_once ('Image/Barcode.php'); Image_Barcode::draw($_GET[NUM], 'int25', 'png'); ?> Seems to work better for me. Many thanks for your assistance Mchl. Hopefully I can crack the others now! Quote Link to comment Share on other sites More sharing options...
fj1200 Posted December 1, 2008 Author Share Posted December 1, 2008 ;D Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Good luck with that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.