Reputation: 1
I am using the google chart to create a QR Code like below
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http://mobile.dogoodperks.com/london/?pg=Home&couponid=<? print "$couponid&perkid=$perkid&pur=entered&city=$city"; ?>&choe=UTF-8" title="Link to Google.com" />
That one does not work and I even tried the one below
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http://mobile.dogoodperks.com/london/?pg=Home&city=London&choe=UTF-8" title="Link to Google.com" />
But it did not work either please help! the qr code is generated however when scanned does not go to the page
Upvotes: 0
Views: 337
Reputation: 1961
I'm assuming your problem is that the querystring parameters (&city=London&..
) are not appended to the url in the QR-code.
This problem can be resolved by urlencoding the url, for example:
Regular url
http://mobile.dogoodperks.com/london/?pg=Home&city=London&choe=UTF-8
Encoded url
http%3A%2F%2Fmobile.dogoodperks.com%2Flondon%2F%3Fpg%3DHome%26city%3DLondon%26choe%3DUTF-8
In php this can be achieved using the urlencode-function, for your example this would be:
<?php
$qr_url = "http://mobile.dogoodperks.com/london/?pg=Home&couponid=".$couponid."&perkid=".$perkid."&pur=entered&city=".$city;
$qr_url_encoded = urlencode($qr_url);
echo '<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl='.$qr_url_encoded.'" />';
?>
Upvotes: 1
Reputation: 4512
You have to use echo
and <?php ?>
in url.
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http://mobile.dogoodperks.com/london/?pg=Home&couponid=<?php echo "$couponid&perkid=$perkid&pur=entered&city=$city"; ?>&choe=UTF-8" title="Link to Google.com"/>
Upvotes: 0