Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从MySQL数据创建二维码?_Php_Mysql_Joomla_Qr Code - Fatal编程技术网

Php 如何从MySQL数据创建二维码?

Php 如何从MySQL数据创建二维码?,php,mysql,joomla,qr-code,Php,Mysql,Joomla,Qr Code,我需要一个脚本,使用MySQL数据库中存储的用户数据创建二维码。每次用户访问其数据时,都应该加载它。我做了一些研究,发现了一个适合我需要的图书馆:。我抓取了一个示例在我的网站()中进行测试,并修改了代码: <?php include('../libraries/phpqrcode/qrlib.php'); include('configuration.php'); // how to build raw content - QRCode with simple Business Ca

我需要一个脚本,使用MySQL数据库中存储的用户数据创建二维码。每次用户访问其数据时,都应该加载它。我做了一些研究,发现了一个适合我需要的图书馆:。我抓取了一个示例在我的网站()中进行测试,并修改了代码:

<?php
include('../libraries/phpqrcode/qrlib.php'); 
include('configuration.php'); 

// how to build raw content - QRCode with simple Business Card (VCard) 

$tempDir = EXAMPLE_TMP_SERVERPATH; 

// here our data 
$name = 'John Doe'; 
$phone = '(049)012-345-678'; 

// we building raw data 
$codeContents = 'BEGIN:VCARD'."\n"; 
$codeContents .= 'FN:'.$name."\n"; 
$codeContents .= 'TEL;WORK;VOICE:'.$phone."\n"; 
$codeContents .= 'END:VCARD'; 

// generating 
QRcode::png($codeContents, $tempDir.'025.png', QR_ECLEVEL_L, 3); 

// displaying 
echo '<img src="'.EXAMPLE_TMP_URLRELPATH.'025.png" />'; 
?>

但是,它给了我这个错误:

警告:include(../libraries/phpqrcode/qrlib.php):打开失败 流:中没有这样的文件或目录 /home/u9072349/public_html/plugins/system/sourcerer/helper.php(632) :运行时在第7行创建的函数警告: include(../libraries/phpqrcode/qrlib.php):未能打开流:否 中的此类文件或目录 /home/u9072349/public_html/plugins/system/sourcerer/helper.php(632) :运行时在第7行创建的函数警告:include():失败 打开“../libraries/phpqrcode/qrlib.php”以包含 (包括_path='。:/usr/lib/php') /home/u9072349/public_html/plugins/system/sourcerer/helper.php(632) :运行时在第7行创建函数致命错误:无法重新声明 上的/home/u909072349/public_html/configuration.php中的JConfig类 第2行 我已经检查了qrlib.php文件,内容如下:


在包含文件时,您尚未定义基本路径

尝试使用以下方法:

include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php'); 
include('configuration.php'); 
<?php

   include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php');

   $tempDir = JPATH_SITE . '/images/';   
   $codeContents = 'This Goes From File';
   $fileName     = 'qr_'.md5($codeContents).'.png';

   $pngAbsoluteFilePath = $tempDir.$fileName;
   $urlRelativeFilePath = JUri::root() .'images/' . $fileName;

   if (!file_exists($pngAbsoluteFilePath)) {
      QRcode::png($codeContents, $pngAbsoluteFilePath);
   }
   else {
      echo "Not working!";
   }

   echo '<img src="'.$urlRelativeFilePath.'" />';

?>
我不确定为什么需要包含configuration.php文件,但是这不是一个好主意。如果您需要从这个文件中获取任何值,Joomla有自己的API来实现这一点

更新: 您没有正确定义路径。使用以下命令:

include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php'); 
include('configuration.php'); 
<?php

   include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php');

   $tempDir = JPATH_SITE . '/images/';   
   $codeContents = 'This Goes From File';
   $fileName     = 'qr_'.md5($codeContents).'.png';

   $pngAbsoluteFilePath = $tempDir.$fileName;
   $urlRelativeFilePath = JUri::root() .'images/' . $fileName;

   if (!file_exists($pngAbsoluteFilePath)) {
      QRcode::png($codeContents, $pngAbsoluteFilePath);
   }
   else {
      echo "Not working!";
   }

   echo '<img src="'.$urlRelativeFilePath.'" />';

?>


希望这有帮助

谢谢房客。我会尽快检查它。好吧,现在我没有得到错误,但它什么也不显示。看,它应该出现在图像图标所在的位置。@DaniValverde-我已经更新了我的答案。确保你复制了所有的图片,因为我也添加了一些东西。我仍然只得到一张图片,iconI需要在我的机器上测试。我过一会儿再来找你