php - MySql empty result set returns different formats -


i trying execute 2 simple select queries on 2 different tables in mysql server. doing running php script. both queries supposed return empty result set. returning different formats.

city table returning simple null value dealer table returning columns null values.

output:

{**"dealer"**:[{"car_make":null,"state":null,"city":null,"company_name":null,"company_address":null,"phone":null,"mobile":null,"fax":null,"email":null,"website":null,"data_version":null}],**"city"**:null} 

php script

<?php  $data_version = 5;  require 'dbconnect.php';   $query = ("select * `dealer` `data_version` > $data_version");   if ($query_run = mysql_query($query)){      while ($query_row = mysql_fetch_assoc($query_run)){          $out [] = $query_row;      }  } else{     echo 'fail'; }    $query1 = ("select * `city` `data_version` > $data_version");   if ($query_run1 = mysql_query($query1)){      while ($query_row1 = mysql_fetch_assoc($query_run1)){          $out1 [] = $query_row1;      }  } else{     echo 'fail'; }    $output=array('dealer'=>$out,'city'=>$out1);       echo(json_encode($output));  ?> 

so due varying formats not able handle it. reason such varying formats? should have same kind of results??

table schemea

dealer table "car_make","state","city","company_name","company_address","phone","mobile","fax","email","website","data_version"

city table

city, state, data_version

(all fields varchar(50) )

output of printing

array ( [dealer] => array ( [0] => array ( [car_make] => [state] => [city] => [company_name] => [company_address] => [phone] => [mobile] => [fax] => [email] => [website] => [data_version] => ) )[city] => )

it might possible due 2 reasons:-

there no row match query in city table return null value.

in case of dealer table might returning row in values null.

please check!


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -