我试图从数据库中获取数据并生成图形。我正在使用phpgraphlib,http://www.ebrueggeman.com/phpgraphlib/documentation/tutorial-mysql-and-phpgraphlib。我从https://github.com/libgd/libgd/releases下载了libgd
还有phpgraphlib。我有PHP 5.5和php_gd2.dll扩展名,我认为默认情况下在php.ini文件中启用了它。

我收到2个错误:


  警告:require_once(phpgraphlib.php):无法打开流:否这样
  第3行的C:\ XAMPP \ htdocs \ graph.php中的文件或目录
  
  致命错误:require_once():无法打开所需的“ phpgraphlib.php”
  (include_path ='.; C:\ XAMPP \ php \ PEAR')在C:\ XAMPP \ htdocs \ graph.php中
  3号线


我还强调路径和目录出了问题。有什么帮助吗?提前致谢!!!

    <?php

      require_once("phpgraphlib.php");
      $graph=new PHPGraphLib(400,300);

     //connection to MySQL database

    $link =mysql_connect('localhost','root','') or die('Could not connect :'. mysql_error());

    //select db
    mysql_selected_db('mynewdb') or die('Could not select database');

   $dataArray=array();

   //get data from database
    $sql="SELECT year1,year2 * FROM scores WHERE crit='interesting semester' AND sid='13'";
    $result = mysql_query($sql) or die('Query failed: ' . mysql_error());

   if ($result) {
         while ($row = mysql_fetch_assoc($result)) {
            $crit=$row["crit"];
            $year1=$row["year1"];
            $year2=$row["year2"];
           //add to data array
            $dataArray[$crit]=$count;
         }
   }

       //configure graph
         $graph->addData($dataArray);
         $graph->setTitle("Interesting Semester");
         $graph->setGradient("lime", "green");
         $graph->setBarOutlineColor("black");
         $graph->createGraph();

   ?>

最佳答案

请将您的文件phpgraphlib.php放在./或C:\ XAMPP \ php \ PEAR

关于php - PHP中的图形错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28765839/

10-11 13:00