title: iPhone sending POST with NSURLConnection
body: <p>I'm having some problems with sending POST data to a PHP script with NSURLConnection. This is my code:</p>
  
  <pre><code>    const char *bytes = [[NSString stringWithFormat:@"&lt;?xml version=\"1.0\"?&gt;\n&lt;mydata&gt;%@&lt;/mydata&gt;", data] UTF8String];
  
      NSURL *url = [NSURL URLWithString:@"http://myurl.com/script.php"];
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  
      [request setHTTPMethod:@"POST"];
      [request setHTTPBody:[NSData dataWithBytes:bytes length:strlen(bytes)]];
  
      NSURLResponse *response;
      NSError *err;
      NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;err];
      NSLog(@"responseData: %@", responseData);
  </code></pre>
  
  <p>And my script.php is as simple as this:</p>
  
  <pre><code>&lt;?php
      echo $_POST['mydata'];
  ?&gt;
  </code></pre>
  
  <p>This have worked for me in the past, but for some reason the output I get from <code>NSLog(@"responseData: %@", responseData);</code> now is just "&lt;>" instead of "theData".</p>
  
  <p>Probably some lame mistake somewhere but I can't seem to find it? Any ideas?</p>