Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:19:31+00:00 2026-06-11T08:19:31+00:00

I am trying to JSON_encode data from a MySQL database. The characters in the

  • 0

I am trying to JSON_encode data from a MySQL database. The characters in the DB are as should.

For example, some of the data contains this: è

When I print out to the browser, this is what I get for all items that have special characters:

{"category":null}

Here is the very basic watered down version of the code I am using to test:

$sql = mysql_query("SELECT category FROM master_cat ORDER BY category ASC");
    while ($row = mysql_fetch_assoc($sql))
        $output[] = $row;

print(json_encode($output));

How can I get actual data to appear in browser when I am reading the JSON on the web page and not null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:19:33+00:00Added an answer on June 11, 2026 at 8:19 am

    You could use utf8_encode on the text fields, but can you check that the data is, indeed, there? Maybe output the data in HTML instead of JSON-encoding it? Because on my system UTF8 is either recognized, gives error, or some characters are truncated.

    NULL smells of database data missing.

    If the data is there, then:

    mysql_query('SET NAMES utf8;');
    $sql = mysql_query("SELECT category FROM master_cat ORDER BY category ASC");
    while ($row = mysql_fetch_assoc($sql))
        $output[] = array_map('utf8_encode', $row);
    
    print(json_encode($output));
    

    You might want to specify explicitly the MIME type and charset too:

    Header('Content-Type: application/json; charset=UTF-8');
    

    see What is the correct JSON content type?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save the data retrieved from the database into a .json. This
I'm was trying a tutorial to get data to android from a MySQL database
I am trying to get data from MySQL database but in the php file
I've been trying to Base64 encode image data from the user (in this case
Im trying to retrieve some data from JSON object which holds location information such
I am trying to fetch data from database using php and send it to
I'm retrieving data from MySql with php like this => while ($birthday_row = $birthday_r->fetch_row()){
I am pulling data from my database and trying to encode into JSON data
I'm trying to load some data via. jquery $get_desc = SELECT tekst_id,overskrift FROM rr_tekster
im trying out something new for me that's working with a MySQL database using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.