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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:17:19+00:00 2026-06-13T08:17:19+00:00

I’m trying to parse JSON Using ASIHttpRequset I wrote this code -(void) tryASIHttpRequest{ NSString

  • 0

I’m trying to parse JSON Using ASIHttpRequset
I wrote this code

-(void) tryASIHttpRequest{

NSString *phpUrl = @"http://www.myURL.com/subfolder/myFile.php";

NSString *dbName = @"dbName";
NSString *localHost = @"localhost";
NSString *dbUser = @"dbUser";
NSString *dbPwd = @"password";

NSString *S_user_id = [NSString stringWithFormat:@"%d",u_id0];


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

NSURL *link = [NSURL URLWithString:[phpUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:link];

[request setRequestMethod:@"POST"];
[request setPostValue:dbName forKey:@"dbName"];
[request setPostValue:localHost forKey:@"localHost"];
[request setPostValue:dbUser forKey:@"dbUser"];
[request setPostValue:dbPwd forKey:@"dbPwd"];
[request setPostValue:S_user_id forKey:@"user_id"];
[request setPostValue:@"" forKey:@"submit"];

[request setTimeOutSeconds:120];
[request setDelegate:self];
NSError *error = [request error];

[request startAsynchronous];

if (!error) {
    NSData *response = [request responseData];
    NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

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

    for (NSDictionary *status in statuses)
    {

        NSString *bo_id2 = [status objectForKey:@"bo_id"];
        NSString *bo_name2 = [status objectForKey:@"bo_name"];

        NSLog(@"from server using ASIHttpRequest");
        NSLog(@"bo_id: %@ - bo_name: %@", bo_id2, bo_name2);

    }    

}else{
    NSLog(@"ASIHttp Error: %@", error);
}
}

and in bookOwn.php I wrote the following

<?php 
if (isset($_POST['submit'])) {

$dbName = $_POST['dbName'];
$localHost = $_POST['localHost'];
$dbUser = $_POST['dbUser'];
$dbPwd = $_POST['dbPwd'];
$user_id  = $_POST['user_id'];

$con = mysql_connect($localHost,$dbUser,$dbPwd);
$db_found = mysql_select_db("iktab_book");

mysql_query('SET CHARACTER SET UTF8');
mysql_query("SET NAMES utf8; ");

$check = mysql_query("SELECT * FROM d_book where bo_id IN (Select Distinct(sal_bo_id) From d_sales Where sal_user_id =" . $user_id . ")");

while($row=mysql_fetch_assoc($check))
$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);

mysql_close();

}
?>

if the code is ok, this line will be printed

 from server using ASIHttpRequest

but it doesn’t print and I can’t determine what is the wrong in my code.
Any help ?
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-13T08:17:20+00:00Added an answer on June 13, 2026 at 8:17 am

    It looks like you are doing an asynchronous request [request startAsynchronous]; and then are checking on the next line to see if there is data. Asynchronous means that it will be executed later on. Usually one would become the request’s delegate to get notified when the request was finished loading.

    More Pressing:

    Don’t use ASIHTTPRequest. It has been deprecated by its author. Note the banner on the website advising using something else

    For alternative URL frameworks AFnetworking is popular.

    Also NSURLConnection isn’t that bad.

    And finally if you are targeting iOS 5 or higher (and theres not much reason to support less) you no longer need SBJSON. NSJSONSerialisation is provided by the OS for converting JSON into objects and back again.

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

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.