duandui2803 2018-08-04 11:50
浏览 50

为什么我不能在我的数组中添加php精确数据形式的MySQL?

I am studying android. And I have database in MySQL , I want to transfer some data from database to android to show it like ListView. I have learned that I need PHP , and JSONArray. And that is my colums in MySQL: enter image description here

My code in PHP :

  $query = mysqli_query($con,
           "SELECT * FROM market ORDER BY id ");
  $someArray = [];

  while ($row = mysqli_fetch_assoc($query)) {
    array_push($someArray, [
'id' => $row['id'],
'nick' => $row['nick'],
'percent' => $row['percent'],
'minimum' =>$row['minimum'],
'logo_small' => $row['logo_small'],
'logo_big'  => $row['logo_big'],
'name' =>$row['name'],
'phone'  => $row['phone'],
'position'=> $row['position']
 ]);
  }
      echo json_encode($someArray);

AND It works! what i get : enter image description here BUT when I want to add (or write it instead of getting name or nick or etc.)

'adresses' => $row['adresses']

complete code when add this:

<?php

    $con = mysqli_connect(".....", ".....", ".....", "......."); //private

  $query = mysqli_query($con,
           "SELECT * FROM market ORDER BY id ");
  $someArray = [];

  while ($row = mysqli_fetch_assoc($query)) {
    array_push($someArray, [
'id' => $row['id'],
'nick' => $row['nick'],
'percent' => $row['percent'],
'minimum' =>$row['minimum'],
'logo_small' => $row['logo_small'],
'logo_big'  => $row['logo_big'],
'name' =>$row['name'],
'phone'  => $row['phone'],
'position'=> $row['position'],
'adresses'=>$row['adresses']
 ]);
  }
      echo json_encode($someArray);
?>

or

'description'=> $row['description']

It is not working... when i add these lines(or one of them) i get this (empty): enter image description here

Data in db for adresses and description(i have only 4 titles) enter image description here I can't get adresses and description. What is a problem? maybe in database?

Reason: Because of the special symbols(é, ü, ç) in db there was an error.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程