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 3455060
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:34:03+00:00 2026-05-18T09:34:03+00:00

My searching skills seems to have failed me. I have this php object that

  • 0

My searching skills seems to have failed me. I have this php object that I unserialize from a mysql entry, and I want to pass it as an argument to a javascript function, so it could compare the object with the values in a form. From what I gathered from my search, encoding the object as a json object would have done the trick, but when I’m doing a json_encode on the variable, it only result in {}.

Here is the relevant snippet of code:

<?php
$data = new Data();
$data = unserialize(base64_decode($rawdata));//Where $rawdata is the data retrieved from the mysql query.
/* using function such as $data->getName() to retrieve the relevant data */
?>

<form id="myform" action="#" method="post" onsubmit="compareEntry(<?=json_encode($data)?>)">

<!-- Different input and select field initialized with the php data -->

<input type="submit" onclick="compareEntry(<?=json_encode($data)?>)"/>
</form>
<!--<?=json_encode($data)?>--> 

I know that the php data is correctly retrieved from the database, as the values in the form are all correctly initialized. Only with the last html comment did I knew that I had an empty json object.

Here is an example of what print_r($data) returns (sensitive information edited):

(
    [m_path:private] => 
    [m_version:private] => REL_54
    [m_bugs:private] => Array
 *RECURSION*
    [m_targets:private] => Array
 *RECURSION*
    [m_symptoms:private] => Array
 *RECURSION*
    [m_exception:private] => Array
 *RECURSION*
    [m_instruction:private] => Array
 *RECURSION*
    [m_sources:private] => Array
 *RECURSION*
    [m_risks:private] => Array
 *RECURSION*
    [m_test:private] => Array
 *RECURSION*
    [m_contact:private] => Array
 *RECURSION*
)
1

Do I do something wrong? Is encoding to JSON the right approach in my scenario?

  • 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-18T09:34:04+00:00Added an answer on May 18, 2026 at 9:34 am

    Your object contains private properties only that won’t be output by json_encode.

    Also, there seems to be some sort of recursion going on, probably meaning that a member of each array is referencing the object itself (or something like that).

    You will need to make some of the properties public, and probably also fix the recursion issues.

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

Sidebar

Related Questions

Searching here I found that this question was already asked , but I think
I have been searching all weekend for the solution to this quandry and have
searching a photo by dominant colors using mysql is quite simple. assuming that the
I'm searching for users that match a set of tags. I want to return
I have this MySQL query, and it works on a MySQL database, but not
Searching from google.com, like www.abc.com Search Result Rank the pages like Title..... Description... www.abc.com
Searching online, I have found the following routine for calculating the sign of a
While searching for a proper way to trim non-breaking space from parsed HTML, I've
I searching for and IDE that gives me a (mostly) uniform experience on Linux/Windows
Currently I am working with a commercial project with PHP. I think this question

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.