quique
Posts: 17
Joined: Sat Nov 07, 2015 3:24 am

Code migrated to mysqli and now chart isnt drawn

My stockchart used to work perfectly with mysql code. I had to migrate to mysqli:

co2.php --- this reads the data from the db

Code: Select all

<?php
require_once("connection.php");
//include ("utils.php");
// (include_path='.:/opt/plesk/php/7.2/share/pear') 
include_once("JSON.php");
$json = new Services_JSON();

$sqlChart_Q='SELECT mq2,unix_timestamp(timestamp) FROM example WHERE id > 57000 ORDER BY unix_timestamp(timestamp) ASC';
$sqlChart_R = mysqli_query($conn,$sqlChart_Q);

while($row = $sqlChart_R->fetch_row()) {
      $time=(int)$row[1]*1000;
      $mq2=(float)$row[0]; 
      $arrChart[]=array($time, $mq2);
   }
echo json_encode($arrChart);
$conn->close();
?>
and I get this:
[[1589869534000,0],[1589880428000,735],[1589889504000,527],[1589896763000,488],[1589902200000,390],[1589905800000,399],[1589916709000,437],[1613929195000,33],[1613929195000,34],[1613929254000,35],[1613929254000,36]]
But the page that draws the chart simply comes up blank. Here is its code. Please help:

index4.php --- this is the sample code used for drawing the chart

Code: Select all



<div id="container" style="height: 400px; min-width: 310px"></div>
	</body>
</html>

        
quique
Posts: 17
Joined: Sat Nov 07, 2015 3:24 am

Re: Code migrated to mysqli and now chart isnt drawn

Im unable to post the index4.php file which is the one that draws the chart. Its based off the sample index.php file and it used to work fine.
quique
Posts: 17
Joined: Sat Nov 07, 2015 3:24 am

Re: Code migrated to mysqli and now chart isnt drawn

The co2.php file is generating the array and it is received in the index4.php (drawing) page. But for some reason I just get a blank page when it loads.

Image

And this is the only error in the server log:
AH01071: Got error 'PHP message: PHP Warning: include(utils.php): failed to open stream: No such file or directory in /var/www/vhosts/myserver.com/httpdocs/highstock/examples/uvmq2/temp.php on line 26\nPHP message: PHP Warning: include(utils.php): failed to open stream: No such file or directory in /var/www/vhosts/myserver.com/httpdocs/highstock/examples/uvmq2/temp.php on line 26\nPHP message: PHP Warning: include(): Failed opening 'utils.php' for inclusion (include_path='.:/opt/plesk/php/7.2/share/pear') in /var/www/vhosts/myserver.com/httpdocs/highstock/examples/uvmq2/temp.php on line 26\nPHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysql_pconnect() in /var/www/vhosts/myserver.com/httpdocs/highstock/examples/uvmq2/temp.php:30\nStack trace:\n#0 {main}\n thrown in /var/www/vhosts/myserver.com/httpdocs/highstock/examples/uvmq2/temp.php on line 30\n', referer: http://myserver.com/highstock/examples/uvmq2/index4.php
The complete code is posted in in https://stackoverflow.com/questions/663 ... 8_66308703
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Code migrated to mysqli and now chart isnt drawn

Thanks for message,

Have you read this article about working with MySQL data and Highcharts?
https://www.highcharts.com/docs/working ... a-database

For the future don't repeat question on many support channel, but I think the StackOverflow it's a more general forum for question correlated with mysql.

Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Stock”