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

  • SEARCH
  • Home
  • 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 6640707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:42:16+00:00 2026-05-25T23:42:16+00:00

I inserted on a row of database table values, now I want echo them

  • 0

I inserted on a row of database table values, now I want echo them with json_encode, but I have following error:

PHP:

$name_tour = $this->input->post('tour_name');
$query     = $this->db->query("SELECT * FROM tour_foreign WHERE name LIKE '$name_tour' ORDER BY id desc");
$data      = array();
foreach ($query->result() as $row) {
    $data_rp = json_decode($row->residence_p, true);
    $data[]  = array(
        'residence_p' => $data_rp,
    );
}
echo json_encode($data);
echo '<p>';
var_dump($data);

Output above php code:

[{"residence_p":null}] // This is output of json_encode($data)

array(1) { [0]=> array(1) { ["residence_p"]=> NULL } } // This is output of var_dump($data)

Data in database:(this data insert by json_encode)

[{
    "start_date": ["1111", "2222"],
    "end_date": ["1111", "2222"],
    "price_change": ["1111", "2222"]
}, {
    "start_date": ["3333", "444"],
    "end_date": ["3333", "4444"],
    "price_change": ["3333", "4444"]
}, {
    "start_date": ["5555", "6666"],
    "end_date": ["5555", "6666"],
    "price_change": ["5555", "6666"]
},]

What do i do?

  • 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-05-25T23:42:16+00:00Added an answer on May 25, 2026 at 11:42 pm

    You should remove the , before the last ], otherwise the data is invalid JSON which cannot be correctly parsed by json_decode().

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

Sidebar

Related Questions

I have two tables users registered_members I want to confirm values from user table
What is supposed to happen is that a row gets inserted into a table,
I inserted some values into a table. There is a column whose value is
I successfully created the Database and inserted a row however I cannot Query it
I have a database table with a UNIQUE key on a date column so
I'm using this code to delete a row in a table, but it's not
I'm using apache, php, mysql and code igniter and I have a database set
I want to prevent the database from storing any values bigger than 20 into
I have a table where each row needs a timestamp marking the time it
I have a table called BUILD_INFO and it has the following columns: BUILD_ID BUILD_NAME

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.