Zingchart PHP 包装器问题



我正在尝试使用PHP包装器模块设置Zingchart。

服务器:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial
Running as a VM under VMWare

我在调用 ZC->connect 方法时收到示例代码错误。

因此:

<HTML>
<HEAD>
<script src="zingchart.min.js"></script>
</HEAD>
<BODY>
<h3>Simple Bar Chart (Database)</h3>
<div id="myChart"></div>
<?php
include 'zc.php';
use ZingChartPHPWrapperZC;
$servername = "localhost";
$username = "nasuser";
$password = "password";
$db = "nas";
$myQuery  = "SELECT run_time, time_total from stats";
// ################################ CHART 1 ################################
// This chart will use data pulled from our database
$zc = new ZC("myChart", "bar");
$zc->connect($servername, "3306", $username, $password, $db);
$data = $zc->query($myQuery, true);
$zc->closeConnection();
$zc->setSeriesData($data);
$zc->setSeriesText($zc->getFieldNames());
$zc->render();
?>
</BODY></HTML>

错误:

# php index.php
PHP Fatal error:  Uncaught Error: Class 'ZingChartPHPWrappermysqli' not found in /var/www/html/zc.php:69
Stack trace:
#0 /var/www/html/index.php(22): ZingChartPHPWrapperZC->connect('localhost', '3306', 'nasuser', 'password', 'nas')

第 69 行是:

$this->mysqli = new mysqli($host, $username, $password, $dbName, $port);

运行:

# php -m | grep -i mysql
mysqli
mysqlnd
pdo_mysql

似乎表明我已安装相关软件包。 事实上,如果我尝试正常的 PHP 连接,它可以工作:

<?php
$servername = "localhost";
$username = "nasuser";
$password = "password";
$dbname = "nas";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * from stats limit 10;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["stat_id"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>

输出:

# php db.php
id: 1<br>id: 2<br>id: 3<br>id: 4<br>id: 5<br>id: 6<br>id: 7<br>id: 8<br>id: 9<br>id: 10<br>

有什么想法吗?

谢谢。

我遇到了同样的问题!在mysqli上导入存在一些问题。我改变了

$this->mysqli = new mysqli($host, $username, $password, $dbName, $port);

ZC.php

$this->mysqli = new mysqli($host,$username,$password, $dbName, $port);

并工作。

相关内容

  • 没有找到相关文章

最新更新