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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:58:00+00:00 2026-06-12T17:58:00+00:00

I send 4 different values in a JSONString. I need to somehow (decode?) convert

  • 0

I send 4 different values in a JSONString. I need to somehow (decode?) convert these to PHP values to send it to a MySQL database.

This function sends is to the php file:

- (void)myFuntionThatWritesToDatabaseInBackgroundWithLatitude:(NSString *)latitude longitude:(NSString *)longitude date:(NSString *)stringFromDate 
{
    _phonenumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"];

    NSMutableString *postString = [NSMutableString stringWithString:kPostURL];
    NSString*jsonString = [[NSString alloc] initWithFormat:@{\"id\":\"%@\",\"longitude\":\"%@\",\"latitude\":\"%@\",\"timestamp\":\"%@\"}", _phonenumber, longitude , latitude, stringFromDate];

    [postString appendString:[NSString stringWithFormat:@"?data=%@", jsonString]];
    [postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString ]];
    [request setHTTPMethod:@"POST"];

    [[NSURLConnection alloc] initWithRequest:request delegate:self ];
    NSLog(@"Post String =%@", postString);

    //    LocationTestViewController*locationTestViewController = [[LocationTestViewController alloc]init];
    //    phonenumber = locationTestViewController.telefoonnummer;
    NSLog(@"HERE1 : %@", _phonenumber);

}

And it probably goes wrong in this part:

NSString* jsonString = [[NSString alloc] initWithFormat:@{\"id\":\"%@\",\"longitude\":\"%@\",\"latitude\":\"%@\",\"timestamp\":\"%@\"}", _phonenumber, longitude , latitude, stringFromDate];

This is my log:

2012-10-09 15:32:59.869 MyApp[626:c07] Post String=http://www.yourdomain.com/locatie.php?  data=%7B%22id%22:%220612833397%22,%22longitude%22:%22-143.406417%22,%22latitude%22:%2232.785834%22,%22timestamp%22:%2209-10%2015:05%22%7D

It sends it to this PHP file where the id, longitude, latitude and timestamp needs to be made ready for the MySQL insert

 <?php

    $id = $_POST['id'];
    $longitude = $_POST['longitude'];
    $latitude = $_POST['latitude'];
    $timestamp = $_POST['stringFromDate'];

    $link = mysql_connect('server', 'bla', 'bla') or die('Could not connect: ' . mysql_error());

    mysql_select_db('bla') or die('Could not select database');

    // Performing SQL query
    $query="INSERT INTO locatie (id, longitude, latitude, timestamp) 
    VALUES ($id, $longitude,$latitude,$timestamp)";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    echo "OK";

    // Free resultset
    mysql_free_result($result);

    // Closing connection
    mysql_close($link);
?>
  • 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-12T17:58:02+00:00Added an answer on June 12, 2026 at 5:58 pm

    Try this code:

    $tmpdata = urldecode($_GET['data']);
    $data = json_decode($tmpdata);
    $id = $data['id'];
    $longitude = $data['longitude'];
    $latitude = $data['latitude'];
    $timestamp = $data['stringFromDate'];
    
    $link = mysql_connect('server', 'bla', 'bla') or die('Could not connect')
    
    mysql_select_db('bla') or die('Could not select database');
    
    // Performing SQL query
    $query="INSERT INTO locatie (id, longitude, latitude, timestamp) 
    VALUES ($id, $longitude,$latitude,$timestamp)";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    echo "OK";
    
    // Free resultset
    mysql_free_result($result);
    
    // Closing connection
    mysql_close($link);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send geographic data (latitude & longitude) to a mySQL database with
I want to send multiple values to a different page using a href link.
I have a button that depending on a class value should send different values
How can I send to action of controller different values for same field? Which
I'm investigating if it is possible to send three different Ax 2009 reports to
hi to all i am new to android i have to send my different
I'm implementing a system to send Messages between different parts of a program I'm
I have a handler and I have to send responses to different activities for
I want to send a opened file descriptor between two different programs. So I
I send to my sever this POST petition: name=pepito&friends=pep+mar And I notice what arrives

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.