代码如下:
$result=mysql_query("select g.*,u.ID as companyID,u.company,u.address,u.phone from tblgood g join tbluser u on g.companyID=u.ID where g.code=$code");
while($row=mysql_fetch_array($result))
{
$image=iconv("GBk", "UTF-8//IGNORE", $row['image']);
$tmp=array('goodID'=>$row['ID'],'goodName'=>$row['name'],'goodPrice'=>$row['price'],'memo'=>$row['memo'],'image'=>$image,'companyID'=>$row['companyID'],'companyName'=>$row['company'],'companyAdd'=>$row['address'],'companyPhone'=>$row['phone']);
array_push($arr,$tmp);
}
mysql_close($con);
return json_encode($arr);
其中$row['image']数据库中存放的是图片地址,例如http://www.baidu.com/a.jpg
返回的json 为:/反斜线全部变成了\/
[{"goodID":"1","goodName":"巧乐兹","goodPrice":"2","memo":"haochi ","image":"images\/panda.jpg","companyID":"1","companyName":"柚子小店","companyAdd":"深圳","companyPhone":"05341255"}]
这是怎么回事呢???有那位知道??
你在字符串里面写/会报错的,需要用\转义
mysql里面存的是/ 但是就是json_encode后就变了,不知道怎么办了