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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:33:33+00:00 2026-06-11T06:33:33+00:00

I’m attempting to POST a JSON string that I grab from a MySql database

  • 0

I’m attempting to POST a JSON string that I grab from a MySql database to another php page. Here’s my code for the parent page:

$ResultLists = array();
$counter = 0;
echo "<form target=\"_blank\" enctype=\"multipart/form-data\" method=\"post\" action=\"_popup.php\" name=\"compare\">";

while($data != NULL and $info = mysql_fetch_array( $data ))
{ 
Print "<tr>";
//..
//I printed some data here, but not relevant to problem
//..
$ResultLists[$counter] = $info['ResultList']; //gets JSON string
echo gettype($ResultLists[$counter]); //prints "string"
//echo $ResultLists[$counter]; //prints the whole list (it is a list of lists <--from python)
$var = json_decode($ResultLists[$counter]); //decode JSON string
echo $var[1][0]; //prints wonderfully (I am only printing one value in "array", but it works).

Print '<td><input type="checkbox" name="data[]" value="'.$ResultLists[$counter].'" /></td>';
Print '</tr>';
$counter++;
}
echo '<tr><td><input type="hidden" name="index" value="'.$counter.'" />';
echo '<input type="submit" value ="Compare Data"> </input></td></tr>';

On the child page, I try to get the data:

<?php

$index = $_POST['index'];
echo 'Number of rows: '.$index.'<br>';
$array = $_POST['data'];

$x = 0;

//echo gettype($array);

echo '<b>Type:</b> '.gettype($array[$x]).'<b>  Length:</b> '.strlen($array[$x]).'  <b>Data:</b> '.$array[$x].'<br>';
$var = json_decode($array[$x]);
echo gettype($var).strlen($var);
echo $var[1][0];

?>

Which produces (for example)

Number of rows: 8
Type: string Length: 2 Data: [[
NULL0

So, it doesn’t work. (It does this for every row of data I have submitted, so varying $x results in same output as long as its in the range of number of checkboxes I selected, if that makes sense.) Any ideas? Why does it show up as “[[” instead of the entire list? I can print the whole list on parent page and it works fine.

I have a suspicion its due to the presence of single quote ” ‘ ” characters, or something. Any ideas?

Edit:

So disabling magic quotes seems to have helped me post.

However, I’m having a strange issue, where it somehow submits all my data.

So when I get back data[] via POST, the length is the correct number of checkboxes that were checked, but the data it holds starts from the first row that is printed. Any ideas?

  • 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-11T06:33:35+00:00Added an answer on June 11, 2026 at 6:33 am

    You may probably want to escape the HTML characters in the json-ized string using htmlspecialchars. I.e.,

    Print '<td><input type="checkbox" name="data[]" value="'.htmlspecialchars($ResultLists[$counter]).'" /></td>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.