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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:08:54+00:00 2026-06-05T13:08:54+00:00

here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =

  • 0

here is my php code

$titikPetaInti = array();
while($row = mysql_fetch_assoc($hasil2))
{
     $titikPetaInti[] = $row['koordinat'];
}

$data = "{titikPeta:".json_encode($titikPetaInti)."}";
echo $data;
?>

then here is my android code
xResultTitikPeta is result request to php

jObject = new JSONObject(xResultTitikPeta);
        JSONArray myArray1 = (JSONArray) jObject.getJSONArray("titikPeta");
        String[]titikPeta = new String[myArray1.length()];

        for(int a = 0; a < myArray1.length(); a++)
        {
            titikPeta[a] = myArray1.getJSONObject(a).toString();
        }
        teks1 = (TextView) findViewById(R.id.textView1);
        teks1.setText(Arrays.toString(titikPeta));

it displaying null at emulator like no value

–EDIT–

i think there something mistake in parsing code, cus when i display the xResultTitikPeta in android, it give me string result

here is result of xResultTitikPeta

{titikPeta:["-8.705378,115.225189","-8.56056700000000,115.42395100000","-8.57659700000000,115.40065300000","-8.55596300000000,115.41085700000","-8.51855200000000,115.491908000000","-8.54743200000000,115.41036800000","-8.56551100000000,115.45173900000","-8.44321000000000,115.616019000000"]}
  • 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-05T13:08:56+00:00Added an answer on June 5, 2026 at 1:08 pm

    OK, I’ve found your bug! As well as fixing the $data = json_encode(array("titikPeta" => $titikPetaInti)); issue, the problem is here:

    titikPeta[a] = myArray1.getJSONObject(a).toString();
    

    The elements of myArray1 are actually of type string and cause an exception to be thrown, so you need instead:

    titikPeta[a] = myArray1.getString(a);
    

    This produces the output of:

    [-8.705378,115.225189, -8.56056700000000,115.42395100000, -8.57659700000000,115.40065300000, -8.55596300000000,115.41085700000, -8.51855200000000,115.491908000000, -8.54743200000000,115.41036800000, -8.56551100000000,115.45173900000, -8.44321000000000,115.616019000000]
    

    As each element in your array is of the form "-8.705378,115.225189", the JSON parser assumes they are strings. If you change the elements to "-8.705378","115.225189" you can also use:

    titikPeta[a] = Double.toString(myArray1.getDouble(a));
    

    However, the first version will work too.

    Note: my personal preference is that I would declare each array element as:

    {"x":-8.705378,"y":115.225189}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is some PHP code: $map[1][3]['test'][0]='weee'; $map[4][5]['test'][0]='bleh'; $map[1][3]['bleh'][0]='mooo'; $map[1][3]['bleh'][1]='baaa'; echo map = . json_encode($map)
Here is simple PHP code echo '<form method=POST action=calcbyme.php></br> enter value1 :<input type=text name=f1></br>
Here is my code of Qt creator to send the data to PHP server
Here's my PHP code - for ($i=1;$i<=10;$i++) { $numbers .= $i.\n; } echo <input
Here is my PHP code: echo '<br />1. '.$w_time_no; echo '<br />2. '.strtotime($w_time_no); echo
here is some php code: class A { private function action(){ echo 1; }
I have an ajax code which passes data to php and then retrieves data
Here's my php code <?php $pageOK = array('page0' => 'page0.php', 'page1' => 'content1.php', 'page2'
Here is my code to send the data from android app to php app
Here is my PHP code.. $input = zergling-light $output = str_replace('-', ' (', $input).);

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.