• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

JSONArray and mysqlli

//old mysql conn
$json_arr = array("r1" => $row["r1"],"r2" => $row["r2"] );
  echo json_encode( $json_arr );

return :
{"r1":"3610","r2":"0.0000" }

and this is ok.
//

//new mysql conn
when i use mysqlli
  $row = $rs->fetch_all(MYSQLI_ASSOC);
 echo json_encode( $row );

return:
[{"r1":"3610","r2":"0.0000" }]

and this is not work.

What the problem?

//
0
imediagroup
Asked:
imediagroup
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
I don't see any problem
what about :
$row = $rs->fetch_all(MYSQLI_ASSOC);
 echo json_encode( $row[0] );

Open in new window

0
 
imediagroupAuthor Commented:
i need like this     {"r1":"3610","r2":"0.0000" }

but return     [{"r1":"3610","r2":"0.0000" }]


problem []
0
 
imediagroupAuthor Commented:
oh thanks..

problem is   echo json_encode( $row[0] );  and i use  echo json_encode( $row);
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now