php 5.6到7.x版本代码中面临的mysql问题

lokaqttq  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(206)

我在php版本中遇到了一个问题,当我在5.6中运行时,代码运行得很好。更改为7.x时,代码显示错误:
第25行的/var/www/html/lib/pages/server.php中为foreach()提供的参数无效
代码:

/* select all the weekly tasks from the table googlechart */
$result1 = sql_query($db, "SELECT `date`, `rank` FROM Accounts WHERE `ip` = " . $acc['ip'] . " AND `joined` = " . $acc['joined'] . " GROUP BY `date` DESC");
$rows1 = array();
$table1 = array();
$table1['cols'] = array(
    // Labels for your chart, these represent the column titles.
    /*
    note that one column is in "string" format and another one is in "number" format
    as pie chart only required "numbers" for calculating percentage
    and string will be used for Slice title
    */
array(
    'label' => 'date',
    'type' => 'string'
) ,
array(
    'label' => 'rank',
    'type' => 'number'
)
);
// var_dump($result);
/* Extract the information from $result */

foreach($result1 as $r1) {
    $temp1 = array();
    // The following line will be used to slice the Pie chart
    $temp1[] = array(
        'v' => (string)date('m-d ga', strtotime($r1['date']))
    );
    // Values of the each slice
    $temp1[] = array(
        'v' => $r1['rank']
    );
    $rows1[] = array(
        'c' => $temp1
    );
}
$table1['rows'] = $rows1;
// convert data into JSON format
$jsonTable1 = json_encode($table1);
// var_dump($jsonTable);
// echo $jsonTable1;

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题