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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:29:59+00:00 2026-06-02T20:29:59+00:00

I encountered the following problem: I want so connect my iPhone-App with a database

  • 0

I encountered the following problem:
I want so connect my iPhone-App with a database on a server. Therefore I use some (simple) .php files to manage the access to the DB. Inserting new data already works but I have some trouble to convert fetched data into a NSMutableArray :

NSURL *contentURL = [NSURL URLWithString:[kHOSTURL stringByAppendingString:kGETBarsURL]];
NSLog(@"URL : %@", contentURL);

NSData *contentData = [NSData dataWithContentsOfURL:contentURL];
NSLog(@"Data : %@", contentData);

NSError *e = nil;
NSMutableArray *jsonArray = [NSJSONSerialization JSONObjectWithData:contentData
                                                            options:kNilOptions
                                                              error:&e];
NSLog(@"JSON : %@", jsonArray);
NSLog(@"Error : %@", e);

Output is like this (I ‘XX’ and shortened ‘Data :’) :

2012-04-28 13:49:37.229 XX[14434:f803] URL : http://xx/getBars.php
2012-04-28 13:49:37.389 XX[14434:f803] Data : <5b7b2275 6e697175 65223a22 34222c22 4e616d65 223a2254 65737422 2c224465 7461696c 73223a22 54686973 49734154 65737422 7d2c7b22 ...>
2012-04-28 13:49:37.390 XX[14434:f803] JSON : (null)
2012-04-28 13:49:37.392 XX[14434:f803] Error : Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x6daa610 {NSDebugDescription=Garbage at end.}

If I open the page in a browser it looks like this:

[{"unique":"4","Name":"Test","Details":"ThisIsATest"},
 {"unique":"5","Name":"Test","Details":"ThisIsATest"},
 {"unique":"6","Name":"Test","Details":"ThisIsATest"},
 {"unique":"7","Name":"Test","Details":"ThisIsATest"},
 {"unique":"8","Name":"Test","Details":"ThisIsATest"},
 {"unique":"9","Name":"Test","Details":"ThisIsATest"},
 {"unique":"10","Name":"Test","Details":"ThisIsATest"}]

I’ve also tried other options in NSJSONSerialization but that did not work 🙁 Can anybody help me here ?

2012-04-28 14:18:30.192 XX[14541:f803] Encoding : [{"unique":"4","Name":"Test","Details":"ThisIsATest"},{"unique":"5","Name":"Test","Details":"ThisIsATest"},{"unique":"6","Name":"Test","Details":"ThisIsATest"},{"unique":"7","Name":"Test","Details":"ThisIsATest"},{"unique":"8","Name":"Test","Details":"ThisIsATest"},{"unique":"9","Name":"Test","Details":"ThisIsATest"},{"unique":"10","Name":"Test","Details":"ThisIsATest"}]
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16106315-6']);
  _gaq.push(['_setDomainName', '.xx.de']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
  })();

</script>
  • 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-02T20:30:01+00:00Added an answer on June 2, 2026 at 8:30 pm

    It’s pretty obvious that you indeed have ‘garbage’ at the end. You have a JavaScript block that although is not visible in the browser, it’s still returning from your php script. Remove that and you should be good to go.

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

Sidebar

Related Questions

I want to realize a simple client-server connection using Nodejs. But I've encountered with
I'm doing .NET Localization with resource files and I encountered with following problem: I
I am in the process of changing my git-merge-workflow and encountered following problem: Up
I encountered the following problem, and I don't get any warnings or errors, just
Has anyone encountered the following problem: I have IIS7 running on my computer. On
I'm learning C# and I encountered the following problem. I have two classes: base
While making AutoHotkey-script I encountered the following problem. I need navigate listbox (one position
while designing my user control, i encountered the following problem: i would like to
I have the following problem that other people must have encountered. I am working
I encountered a problem dealing with UTF-8, XML and Perl. The following is the

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.