I have written a php code to make JSON file from mysql database. When I checked the JSON file, it displays some data NULL, though my database has no NULL data.. Here is my PHP CODE:
$selectQuery = "SELECT tour_code, day, schedule_title, details FROM tbl_tour_details WHERE status=0";
$response = array();
$posts = array();
$result = mysql_query($selectQuery) or die ("Errored Query: ".$selectQuery);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_assoc($result))
{
$tour_code = $row['tour_code'];
$day = $row['day'];
$schedule_title = $row['schedule_title'];
$details = $row['details'];
$posts[] = array('tour_code'=>$tour_code, 'day'=>$day, 'schedule_title'=>$schedule_title, 'details'=>$details);
}
}
$response['posts'] = $posts;
$fp = fopen('..//webservices//json//tour_details.json','w');
fwrite($fp, json_encode($response));
fclose($fp);
Here, DATATYPE and Size is:
tour_code = int
day = int
schedule_title = varchar(150)
details = text
My data is look like this:
tour_code =1
day = 3
schedule_title = "Singapore – Genting Highland By Coach (350 KM 5 HRS)"
details = "This Morning Is The Day Of FUN And Adventure For The Family. Enjoy Spectular Rides And Shows At The Ever-Popular Genting Outdoor Theme Park With Its Myriad Attractions For The Young And Old Alike. Take An Exciting Drive In The Antique Car Or Daring Spins On The Roller Coaster, It’s A Magical Adventure Of Fun And Excitement For The Whole Family!
Over Night At Hotel First World Deluxe Or Theme Park Or Awana Resort Or Similar.
(Breakfast, Lunch & Dinner)"
Here is my json file(Which consist if null, /r, /n): json file
Here is my var_dump file(which truncate some data as "...") var_dump file
Here is my print_r($posts)
file(which is totally correct):
print_r($posts file
)