Help !! Php + ajax + json at the end of this post, the function & nbsp; gtou ($ s) & nbsp ;{& nbsp; return & nbsp; was edited by zl2727 from 2013 to 12-10:08:23; iconv (gbk, & nbsp; UTF-8, & nbsp; $ s); & nbsp ;}$ proquery & nbsp; help !! Php + ajax + json
This post was last edited by zl2727 at 18:08:23
function gtou($s) { return iconv('gbk', 'utf-8', $s); }
$proquery ="select * from pro where typeid='".$id."' order by corank asc";
$dsql->SetQuery($proquery);
$dsql->Execute();
$a=array();
while($row = $dsql->GetArray())
{
$a[]= array_map('gtou', $row);
}
$res = array(
"status" => "1",
"result" => $a,
"moreUrl" => $moreurl, );
echo json_encode($res);
The returned value is {"status": "1", "result": [], "moreUrl": "http: \/wcn"}. The result is null.
If
Echo json_encode ($ res );
Change to the following
// Echo '{"status": "1", "result": [{"id": "1", "typeid": "111", "goodstitle ": "\ u8865 \ u6c34 \ u6da6 \ u80a4 \ u818f \ Alibaba \ u7684 \ Alibaba \ u597d \ Alibaba \ u8865 \ Alibaba \ u76ae \ u80a4 \ u6709 \ u5f39 \ u6027 ", "goodsurl": "http: \/www. \/uploads \/allimg \/c131205 \/13V23912150-114L_lit.jpg "," brandtitle ":" \ u7f8e \ u5b9d \ u83b2 "," brandurl ":" http :\// www. \/dsadasdas \/"," imgurl ":" http: \/www. \/sadas213 \/"," price ":" 59.9 "," corank ":" 1 "},{" id ":" 2 "," typeid ": "111", "goodstitle": "\ u8865 \ u6c34 \ u6da6 \ u80a4222", "goodsurl": "http: \ // www. \/uploads \/allimg \/c131205 \/13V23912150-114L_lit.jpg "," brandtitle ":" \ u7f8e222 "," brandurl ":" http: \ // www. \/dsadasdas \/"," imgurl ":" http: \/www. \/sadas213 \/"," price ":" 59.9 "," corank ":" 1 "}]," moreUrl ":" http: \/jianfei. \/shuiguo \/"} '; that's correct. Please help the moderators and instruct them again.
Share: More
------ Solution --------------------
Output with var_dump
------ Solution --------------------
Print_r ($ a); check out