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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:47:09+00:00 2026-05-30T18:47:09+00:00

I am working on a application where I need to save some long text

  • 0

I am working on a application where I need to save some long text to MySQL database using PHP web service. I have created web services but I am not able to send parameter from iPhone to PHP web service. Following is my code for web service:

<?php
require_once('config.php');
$username = $_POST["username"];
$aboutme = $_POST["aboutme"];

$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Connection to database failed: ' . mysql_error());
mysql_select_db(DB_DATABASE) or die ('select_db failed!');
$query = "insert into Member(username, aboutMe) values(.'".$username."', '".$aboutme."')";
echo $query;
$result = mysql_query($query) or die(mysql_error());
echo $result;
mysql_close($con);
?>  
 

I have found code to post data to web service but I am not able to add data to post request.

status=[NSString stringWithFormat:@"username=%@&password=%@&interestedIn=%@&aboutme=%@&profilePic=%@&isFBLogin=%@&useFacebookPic=%@",[@"aaaaaaaaaa" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"bbbbbb" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"female" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"about meeeeeeeee" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"profile.png" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"0" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[@"0" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
    //status = @"username=pankaj1234&aboutme=Hello Baby 1234567890 0987654321";
    NSData *postData = [status dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSData *postData = [status dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.example.com/registerUser.php"]];
    [request setURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];
    
    NSURLResponse *response;
    NSError *error;
    [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSLog(@"success!");

How will I add these values to the request?

  • 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-05-30T18:47:10+00:00Added an answer on May 30, 2026 at 6:47 pm

    Your are posting a www form, but you don’t encode the data properly.

    A form has the following syntax: key=value&key=value where both key/value are url encoded.

    Your encoded string (‘status’) should be encoded as the following:

    status=[NSString stringWithFormat:@"username=%@&aboutme=%@",[username stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[about stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
    

    You can then use the rest of the code to convert it to NSData and post to your webservice.

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

Sidebar

Related Questions

I need to have a working web browser in a fullscreen Direct3D application. For
I'm working on a web-application and need to figure out the best way to
We've been working on web application where in we need to implement traditional web-apps
I need to save a NSMutableDictionary in NSUserDefaults. I have searched the web for
Hello Everyone, I am working on an application in which i need to save
The application that I am working on is a Service Desk App. I have
I am working on an application where i need to transfer mails from a
I'm working on an application where I need to generate unique, non-sequential IDs. One
I am working on an application where I need to integrate the search engine.
I'm working in a .net application where we need to generate XML files on

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.