0

I execute this select statement on my table

$get_ads_by_category_query = "select name from sorvy_djcf_items where cat_id='38'";

if(mysqli_select_db($conn,'joyshopp_adds')){

    $result = mysqli_query($conn, $get_ads_by_category_query);

    if( mysqli_num_rows($result) > 0 ){
       $row = mysqli_fetch_row($result;
       echo $row[0];
    }

When I execute this query return Malformed JSON: Unexpected '?' in browser do you know why this happen???

Do you have a solution?

I also saw this How to convert an entire MySQL database characterset and collation to UTF-8? and tried to change the database collation to utf8 but it did not worked...

Community
  • 1
  • 1
Edalat Feizi
  • 1,371
  • 20
  • 32

1 Answers1

0

Use json_encode to return a JSON response.

echo json_encode($row[0]);
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • That sounds like it may be a collation issue, I'm not sure. But you're not getting the "Malformed JSON" error any more, are you? – Barmar Jan 21 '16 at 22:09
  • i know it may be a collation issue but i changed database collation to utf8_general_ci but not worked,i also get "Malformed JSON:N" – Edalat Feizi Jan 21 '16 at 22:21