JSONArray and mysqlli

Posted on 2014-07-14
Last Modified: 2014-07-14
//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 );

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

and this is not work.

What the problem?

Question by:imediagroup
    LVL 81

    Accepted Solution

    I don't see any problem
    what about :
    $row = $rs->fetch_all(MYSQLI_ASSOC);
     echo json_encode( $row[0] );

    Open in new window


    Author Comment

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

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

    problem []

    Author Comment

    oh thanks..

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

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now