1

I've been playing with PHP QR Code all day and I can’t seem to get a QR code to actually print to screen. I’ve read through the documentation and I’ve tried a few different methods I found online but I just can't get a QR code to output to the screen. Here’s the code I'm using per the instructions in the documentation:

 <?php

 header("Content-type: image/png");
 include ("phpqrcode/qrlib.php");
 QRcode::png('some othertext 1234');


 ?>

According to the documentation this code should output a QR code which would give the text inside the parentheses.

1
  • I thought Id add that I just need to figure out how to get it to output correctly. Ive seen the google api that outputs qrcodes but I dont want to use that on my site. Jan 10, 2012 at 0:12

2 Answers 2

1

Have you set your headers so your browser knows to render the QR code as an image?

header("Content-type: image/png");

If you are setting your header (or phpqrcode does it for you, I can't remember) but you're not getting the image, see if you are getting any php errors or warnings that are inadvertently echoing out in the output stream, that will cause problems rendering your image. Ditto for any other chars you may be accidentally outputting.

9
  • Hey thanks for the reply :) I do have that in my code....I resubmitted my question up above to reflect how I have it inserted. Also I dont have any errors related to the phpqrcode library. Jan 10, 2012 at 0:21
  • 1
    Did you look at the raw response to see if there is anything other than the png data? You may be seeing something like this: PHP Warning: blah blah blah âPNG IHDR’FásBIT... which won't render. Jan 10, 2012 at 0:26
  • 1
    IIRC error reporting and error logging are controlled by different settings in php.ini. What happens if you use cURL or fiddler (or some other tool) to examine the raw data coming back from the server? Jan 10, 2012 at 0:36
  • 1
    On win, I use fiddler, on mac I use Charles web proxy. Basically you run the app and you can see each http request on your client and inspect each one. Jan 10, 2012 at 3:07
  • 1
    let us continue this discussion in chat Jan 10, 2012 at 3:48
-1

If you use linux, try installing this:

sudo apt-get install php5-gd

linux's xampp wont generate .png because this apt not installed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.