Creating vCard QR Code
Solution 1
The double quote is being encoded into the QR Code, it should work if you remove these (and should avoid error as any special characters are encoded).
Removing the quotes gives me this QR Code which seems to work:
Solution 2
Just change:
echo 'img src="http://chart.apis.google.com/chart?chs=500x500&cht=qr&chld=H&chl="' . urlencode($vcard) . '"/';
to:
echo 'img src="http://chart.apis.google.com/chart?chs=500x500&cht=qr&chld=H&chl=' . urlencode($vcard) . '"/';
This is because you are closing, with the " the SRC from the TAG <img>
.
Bird87 ZA
By Day: Web Developer for a company in Düsseldorf, Germany. By Night: Couch potato. I love breaking away from coding just to watch some series, game a bit and just general relaxing. Also, I love stuffing my face with Pizza. For fun: Cricket. I play indoor and outdoor cricket, both just socially. Random fact: I don't have any qualifications in what I do.
Updated on June 11, 2022Comments
-
Bird87 ZA almost 2 years
I've got a PHP script that generates a business card template from details entered on the website.
We've recently decided to add QR Code vCards to the business cards as an easy way to save contact info. I am using this tutorial as a starting point.
However, my QR Code does not work. It keeps giving me no result and format as text.
Here is the script that creates the vcard and displays the qr code:
$vcard = "BEGIN:VCARD\r\nVERSION:3.0\r\n N:" . $_POST['surname'] . ";" . $_POST['name'] . "\r\n FN:" . $_POST['name'] . " " . $_POST['surname'] . "\r\n ORG:Example Organisation\r\n TITLE:" . $_POST['position'] . " [" . $_POST['qualification'] . "]\r\n TEL;TYPE=work,voice:" . $_POST['telephone'] . "\r\n TEL;TYPE=cell,voice:" . $_POST['cellno'] . "\r\n TEL;TYPE=work,fax:" . $_POST['fax'] . "\r\n URL;TYPE=work:www.example.com\r\n EMAIL;TYPE=internet,pref:" . $_POST['email'] . "\r\n REV:" . date('Ymd') . "T195243Z\r\n END:VCARD"; echo '<img src="http://chart.apis.google.com/chart?chs=500x500&cht=qr&chld=H&chl="' . urlencode($vcard) . '"/>';
Any assistance?
-
Bird87 ZA over 11 yearsGreat. Something as small as quotes... It's always something small. Thanks for the assistance.