I have been using your code successfully for quite some time now. However I have a problem with producing the same(or similar) QR code multiple times. It seems that once I run the code once it successfully saves the QR code to a file. The second time I run the code with with same parameters (except the filename which I change by augmenting the end with '-1.jpg', '-2.jpg', etc.) it will produce the same code successfully again. However, if the same code is run three or more times it will not produce a QR code saving it to a file.

The contents of the QR code is a url which is consistent each time I run the code. I tried to change the url by passing different variables to the url each time I ran the code such as '?uid=45' but this did not resolve the problem.

The purpose of my code is to add a QR code to a coupon. In some cases a business does not mind for a client to download the same coupon multiple times. Here's where the problems occurs; when a client wants to download the same coupon a third time or more.

What change can I do/change so that the code will save the same content to a QR code sent to a file each time it is run? Here is my code:

recordCoupon($busid, $userid, $adnum, $fileName); //generate QR Code and merge with coupon if (!file_exists($pngAbsoluteFilePath)) { define('IMAGE_WIDTH',285); define('IMAGE_HEIGHT',285); QRcode::png($codeContents, $pngAbsoluteFilePath); //Merge qrcode with coupon $srcFile = "images/avatars/buscredits/buscoupons/".$buscoupon; $qrcodePNG = "images/avatars/buscredits/coupons/".$fileName; //create copy of coupon and save $dest = imagecreatetruecolor(718, 1052); $src = imagecreatefromjpeg($srcFile); imagecopyresampled($dest, $src, 0, 0, 0, 0, 718, 1052, 718, 1052); //merge QR code with Coupon $src2 = imagecreatefrompng($qrcodePNG); imagecopymerge ($dest, $src2, 217, 687, 0, 0, 285, 285, 100); //Save coupon with Qr code to file imagejpeg($dest,$qrcodePNG); } ?>
 

Last edit: Clineson Redcross 2014-12-20