2017-05-15 12 views
0

私は、このdata.phpファイルを持っています。このファイルは、ODBC接続からMDB Msaccessファイルへのクエリ結果で配列を満たす必要があります。array_push from array from odbc connection not working

<?php 

header('Content-Type: application/json'); 

$con = odbc_connect('MyDB','','pass'); 


if (!($con)) 
{ 
echo "Failed to connect to DataBase: " ; 
}else 
{ 
$data_points = array(); 

     $result =odbc_exec($con, "SELECT CategoryName , Sum(DetalleFacturasA.P_NETO) AS Total, Periodo 
    FROM TheTable 
GROUP BY month(FacturasA.Fecha), year(FacturasA.Fecha), CategoryName;"); 

while(odbc_fetch_row($result)) 
{   
    $NameVal= odbc_result($result,1) ; 

    $YVal=odbc_result($result,2); 

    array_push($data_points,array("y" => $YVal ,"label" => $NameVal));   
} 

echo json_encode($data_points, JSON_NUMERIC_CHECK); 

} 
odbc_close($con); 

?> 

問題は、私は文字列型のフィールドの名前である最初のフィールドを使用している場合、私はJSONを取得傾けることです。しかし、私が最後のフィールドを使用する場合、それは魅力のように動作します。

私が試してみてください。

$point = array("label" => odbc_result($result,['CategoryName']) , "y" => 
odbc_result($result,"Total")); 

しかしdoesntの仕事のどちらか

答えて

0

私はそれがしばらく内部変数に "はutf8_encode" を追加しました。