title: $_POST to SQL update problems problems
body: <p>I am trying to update a SQL table from a PHP script which gets its POST statements from a iPhone app I am trying to develop. The app runs fine, and the connections are there, however I have a feeling that the PHP script isn't picking up what I am sending from the app (since my database is not updated). I am using a standard app - PHP - database setup. </p>
  
  <p>Could someone please check my PHP + post statement from the app side? I have   that is where it's breaking. If I run the PHP script my echo statements (below) are empty. I am posting all the code below.</p>
  
  <p>PHP side</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "username";
  $password = "password";
  $dbname = "myDB";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
      $header = $_POST['header'];
  //    $description = $_POST['description'];
  //    $city = $_POST['city'];
  
    $sql = "UPDATE CityTable SET head=header WHERE id=1";
  
  if ($conn-&gt;query($sql) === TRUE) {
      echo "Record updated successfully";
  } else {
      echo "Error updating record: " . $conn-&gt;error;
  } 
  //    $para = $_POST['parameter'];
  //    $parad = $_POST['parameterData'];
      var_dump($_POST);
      echo '&lt;br&gt;', '&lt;br&gt;';
  
      echo "Header, description and city:" , '&lt;br&gt;', '&lt;br&gt;';
  
      echo "Header : " .$header, '&lt;br&gt;';
      echo "Desc : " .$description, '&lt;br&gt;';
      echo "City : ".$city, '&lt;br&gt;','&lt;br&gt;';
  
  //    echo "Para : " .$para, '&lt;br&gt;';
  //    echo "Parad : ".$parad, '&lt;br&gt;';
  $conn-&gt;close();
  
  ?&gt;
  </code></pre>
  
  <p>My viewcontroller</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController{
      NSMutableData *mutableData;
  
  #define URL            @"http://mydb.com/upload.php"  // change this URL
  #define NO_CONNECTION  @"No Connection"
  #define NO_VALUES      @"Please enter parameter values"
  
  }
  
  - (void)viewDidLoad {
  
      [super viewDidLoad];
  
  }
  
  -(IBAction)sendDataUsingPost:(id)sender{
  
      [self sendDataToServer :@"POST"];
  
  }
  
  -(void) sendDataToServer : (NSString *) method{
  
      NSString *head  = header.text;
      NSString *desc = description.text;
      NSString *cty  = city.text;
  
      if(head.length &gt; 0 &amp;&amp; desc.length &gt; 0 &amp;&amp; cty.length &gt; 0){
  
          serverResponse.text = @"Sending to server...";
  
          NSURL *url = nil;
          NSMutableURLRequest *request = nil;
  
          // Only Difference between POST and GET is only in the way they send parameters
  
          if([method isEqualToString:@"POST"]){
  
              NSString *parameter = [NSString stringWithFormat:@"header=%@&amp;description=%@&amp;city=%@", head, desc, cty ];
              NSData *parameterData = [parameter dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
              url = [NSURL URLWithString: URL];
              request = [NSMutableURLRequest requestWithURL:url];
              [request setHTTPBody:parameterData];
  
          }
  
          [request setHTTPMethod:@"POST"];
          [request addValue: @"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
  
          NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
  
          if(connection)
          {
  
              mutableData = [NSMutableData new];
  
          }else{
  
              serverResponse.text = NO_CONNECTION;
  
          }
  
      }else{
  
          serverResponse.text = NO_VALUES;
  
      }
  
  }
  
  #pragma mark NSURLConnection delegates
  
  -(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *)response
  {
      [mutableData setLength:0];
  }
  
  -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
  {
      [mutableData appendData:data];
  }
  
  -(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
  {
      serverResponse.text = NO_CONNECTION;
      return;
  }
  
  -(void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      NSString *responseStringWithEncoded = [[NSString alloc] initWithData: mutableData encoding:NSUTF8StringEncoding];
      //NSLog(@"Response from Server : %@", responseStringWithEncoded);
      NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[responseStringWithEncoded dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
      serverResponse.attributedText = attrStr;
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
  }
  
  @end
  </code></pre>