Get Null value in Json
Get Null value in Json
Hello. I'm trying to create script which mysql query is using more than 1 INNER JOIN (in script pasted below i'm using only one INNER JOIN but it doesn't work too). Sql query generated by this script is correct (checked by: echo $sQuery; and pasted to phpmyadmin). But when i try to display my json - echo json_encode( $output ); - in column which should be value from geo_city.id i get a NULL value. All other fields are returned correctly from the database. Thanks for help. Greetings
My php code:
[code]
<?php
$aColumns = array(
'engine',
'browser',
'platform',
'version',
'grade',
'geo_city.id'
);
$sIndexColumn = "ajax.id";
$sTable = "ajax";
$sJoin = 'INNER JOIN geo_city ON ajax.id = geo_city.id';
/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "R";
$gaSql['db'] = "";
$gaSql['server'] = "";
/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}
/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}
if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
Fragment of my Json output:
[code]
{"sEcho":0,"iTotalRecords":"57","iTotalDisplayRecords":"57","aaData":[["Trident","Internet Explorer 4.0","Win 95+","4","X",null],["Trident","Internet Explorer 5.0","Win 95+","5","C",null]]}
[/code]
My php code:
[code]
<?php
$aColumns = array(
'engine',
'browser',
'platform',
'version',
'grade',
'geo_city.id'
);
$sIndexColumn = "ajax.id";
$sTable = "ajax";
$sJoin = 'INNER JOIN geo_city ON ajax.id = geo_city.id';
/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "R";
$gaSql['db'] = "";
$gaSql['server'] = "";
/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}
/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}
if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
Fragment of my Json output:
[code]
{"sEcho":0,"iTotalRecords":"57","iTotalDisplayRecords":"57","aaData":[["Trident","Internet Explorer 4.0","Win 95+","4","X",null],["Trident","Internet Explorer 5.0","Win 95+","5","C",null]]}
[/code]
This discussion has been closed.