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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:52:48+00:00 2026-06-12T14:52:48+00:00

I send from an iOs Device a jsonString That looks like this: 2012-10-10 08:50:32.011

  • 0

I send from an iOs Device a jsonString

That looks like this:

2012-10-10 08:50:32.011 Appname[4049:c07] Post String =http://www.yourdomain.nl/locatie.php?data=%7B%22id%22:%220612833397%22,%22longitude%22:%22-143.406417%22,%22latitude%22:%2232.785834%22,%22timestamp%22:%2210-10%2007:56%22%7D

That is when i NSLog it…

So the PHP file looks something like this:

<?php

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



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

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

// Performing SQL query
$query = "INSERT INTO locatie (id, longitude, latitude, timestamp) VALUES (NULL," .   $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);
?>

When i go to yourdomain.nl/locatie.php it says that the it is empty, but that should be because i send the data from my iOs app.

I want that the jSonstring that i can see the id, longitude, latitude and timestamp and put them in my mySQL database, but it strangely doenst work.

I know that the string from the iOs device was sended.

Sorry for my bad english,

Any help would be appreciated.

EDIT

Send it like this:

- (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"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];


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


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

NSURLResponse* response;
NSHTTPURLResponse* httpResponse;
NSError* error;
NSData* responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString* stringResponse = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];

httpResponse = (NSHTTPURLResponse*) response;
int statuscode = [httpResponse statusCode];

if (statuscode == 200)
{
    NSLog(@"Verstuurd");
    // Handle the response here if needed
}
else
{
    NSLog(@"niet verstuurd: %@", stringResponse);
    // Show some form of alert here if needed
}
// release all objects saved to memory
[request release];
request = nil;
[stringResponse release];
stringResponse = nil;

}
  • 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-12T14:52:49+00:00Added an answer on June 12, 2026 at 2:52 pm

    First, this is not JSON, its POST FORMDATA probably. Second, when you open the link (with a browser) – it becomes a GET request, not a POST. Try logging the $_POST in file when doing the request from the iOS device. Like this (first line of PHP file):

    file_put_contents('dump.txt', "POST: \n" . print_r($_POST, true) . "\n\n\n GET: \n" . print_r($_GET, true));
    

    Then do several requests to see the results in “dump.txt” in same dir.

    Also, the query should look like this (if I have guessed your colums right):

    $query = sprintf("INSERT INTO locatie (longitude, latitude, timestamp) VALUES ('%s', '%s', '%d')", mysql_real_escape_string($longitude), mysql_real_escape_string($latitude), (int)$timestamp)  ;
    

    The PHP manual discourages usage of the mysql_real_escape_string though – more on this here:

    http://php.net/manual/en/function.mysql-real-escape-string.php

    EDIT:

    My mistake, so the POSTed data is in fact JSON string – try this:

    if (isset($_POST['data'])) {
        $data = json_decode($_POST['data']);
        $latitude = $data['latitude'];
        $longitude = $data['longitude'];
        $timestamp = $data['stringFromDate'];
        // rest of your code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to develop an iOS application that send files between other devices
I'm trying to create a JSON object that looks like this: { request_type:send_string security_level:0
Ok i need to use json on my iOS application to send/receive data to/from
I'm trying to copy data from an array of character that send from main
In my app, i want to send a file to another iOS device via
I am implementing an iphone application (iOS 4.2) from where I would like to
my Task is to send the G-Sensor Data nearly in realtime from an iOS
I've heard that iOS 5 introduced a feature in which the iOS device can
I need to send the device token required for push notification in iOS to
If I were to send an email from any ios app (non built in

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.