mysql - Json_encode generate null value while try to connect two database -
i have use utf8_unicode_ci collation field of 2 database.for english language , number fine thai language not showed.it show null.i try many way still.but if remove $dbh2 work need both
<?php $timezone = "asia/bangkok"; if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone); $dbh1 = mysql_connect('localhost','user1','pass1', true); $dbh2 = mysql_connect('localhost','user2','pass2', true); mysql_query("set names 'utf8"); mysql_select_db('db1', $dbh1); mysql_select_db('db2', $dbh2); $name=$_get['name']; $data=array(); $search=mysql_query("select * `users` `uname` = '".$name."'",$dbh2); while($a=mysql_fetch_assoc($search)) { $data[]=$a['total_point']; } $find=mysql_query("select * `item` order `item_id` desc",$dbh1); while($r=mysql_fetch_assoc($find)) { $data[]=$r; } echo json_encode($data);
?>
and output
[ "0", { "item_id": "10", "item_band": "gift card", "item_pic": "http://www.puncorp.com/applications/gurulotto/lotto/card_04.png", "item_title": "gift card", "item_detail": null, "item_introduction": null, "item_point": "30000", "item_point_bg": "0", "item_available": "97", "item_rule": null, "item_expired": "30/12/2556", "item_confirm_deal": null, "item_confirm_use": null, "item_image_total": "10", "item_image1": "http://www.puncorp.com/applications/gurulotto/lotto/card_04.png", "status": "6" } ]
Comments
Post a Comment