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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:53:26+00:00 2026-06-14T10:53:26+00:00

I’m using php files to get data from mysql to iPhone app, to illustrate

  • 0

I’m using php files to get data from mysql to iPhone app, to illustrate my mean I used this code in php

<?php

$host = "localhost";
$user_name = "user_name";
$password = "password";
$db_name = "db_name";
$con = mysql_connect($host,$user_name,$password)or die (mysql_error());
mysql_select_db($db_name)or die (mysql_error());
mysql_query("set names utf8");

$SQL= "SELECT * FROM emails WHERE 1";

$RS = mysql_query($SQL) or die(mysql_error());
mysql_query("set character_set_server='utf8'");

while($row=mysql_fetch_assoc($RS))
$output[]=$row;

    $json_encode =json_encode($output);
    $utf8_decode = utf8_decode($json_encode);
    echo $json_encode;
    mb_convert_encoding($json_encode, 'UTF-8');
    $html_entity_decode = html_entity_decode($json_encode);

?>

and in iPhone I used this code:

NSString *phpUrl = @"url of my php file";

SBJsonParser *parser = [[SBJsonParser alloc] init];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:phpUrl]];

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

NSArray *statuses = [parser objectWithString:json_string error:nil];

for (NSDictionary *status in statuses)
{
    NSString *sEmailID = [status objectForKey:@"ID"];
    NSString *sEmail = [status objectForKey:@"Email"];
    NSString *sPassword = [status objectForKey:@"Password"];
    NSString *sSMTP = [status objectForKey:@"SMTP"];
}

and this works ok for me and I got my data. I also uses this way many times in my app.
But my problem is that the request and response leads to decrease the speed of my app and made it works so slowly. Is there are any ways to decrease the speed of request and response or is there are any alternative ways instead of this?
Thanks in advance.

  • 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-14T10:53:27+00:00Added an answer on June 14, 2026 at 10:53 am

    The problem is that you’re sending a synchronous request, and this will block your thread until the request completes. In general, this is not recommended, also because you cannot properly handle errors. You should perform asynchronous requests instead. Something like this:

    NSString *phpUrl = @"url of my php file";
    
    SBJsonParser *parser = [[SBJsonParser alloc] init];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:phpUrl]];
    
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
        if (error != nil) {
            NSLog(@"%@", error);
            return;
        }
    
        NSString *json_string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    
        NSArray *statuses = [parser objectWithString:json_string error:nil];
    
        for (NSDictionary *status in statuses)
        {
            NSString *sEmailID = [status objectForKey:@"ID"];
            NSString *sEmail = [status objectForKey:@"Email"];
            NSString *sPassword = [status objectForKey:@"Password"];
            NSString *sSMTP = [status objectForKey:@"SMTP"];
        }
    }];
    

    RTM for more details.

    • 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
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.