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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:37:02+00:00 2026-06-09T00:37:02+00:00

Hi i have problem in sending GET request to a PHP, same PHP works

  • 0

Hi i have problem in sending GET request to a PHP, same PHP works fine when running it in web browser
here are the code snippet of both the PHP and Obj-C
PHP

$var1=$_GET['value1'];
$var2=$_GET['value2'];

when i call this in browser like http://sample.com/sample.php?value1=hi&value2=welcome
it works fine, but from obj c i could’t get succeed
obj C

 NSString *url =[NSString stringWithFormat:@"http://sample.com/sample.php"];
    NSData *data = [@"sample.php" dataUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"%@",url);
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
    [req setHTTPMethod:@"GET"];
    [req setHTTPBody:data];
    NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:req delegate:self]autorelease];
    [connection start];

Please help?

  • 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-09T00:37:03+00:00Added an answer on June 9, 2026 at 12:37 am

    The problem is that you set HTTPBody (by calling setHTTPBody on your request object) whilst GET-requests doesn’t have a body, the passed data should be appended to the url instead. So to mimic the request your did in your browser it would simply be like this.

    NSString *url =[NSString stringWithFormat:@"http://sample.com/sample.php?value1=hi&value2=welcome"];
    NSLog(@"%@",url);
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
    [req setHTTPMethod:@"GET"]; // This might be redundant, I'm pretty sure GET is the default value
    NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:req delegate:self]autorelease];
    [connection start];
    

    You should of course make sure to properly encode the values of your querystring (see http://madebymany.com/blog/url-encoding-an-nsstring-on-ios for an example) to make sure that your request is valid.

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

Sidebar

Related Questions

I have a problem sending POST request with VB6. The code below works properly
I have the following problem. A web service is sending a JSON POST request
I have a problem with sending POST http request. It stops on (HttpWebResponse)request.GetResponse() and
Hi I have a problem in sending data from php to pdf. I think
I have a problem; I want to write a java code for sending an
I have a problem when trying to send a POST request. The sending method
We use VisualSVN server here at work and everything works fine, we have over
I have a button which is sending a get request over XHR to a
I am sending a HTTP GET request to the web service of an external
I have a problem when sending asynchronous request to server, the url of server

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.