I have a table ('attributes') of data with three columns (created, temp and hum).
I need to write a php script to remove this data in JSON format in order for it to be charted with the ChartJS framework.
I have the following code so far but the script returns "Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\charttest\query.php on line 16"
<?php
$DBServer = 'localhost';
$DBUser = 'root';
$DBPass = '';
$DBName = 'digiplant_system';
$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
trigger_error('Could not connect to database!' . $conn->connect_error, E_USER_ERROR);
}
$sql="Select * from attributes";
$l= array();
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$l[] = $row;
}
$j = json_encode($l);
echo $j;
?>