title: sending a post from iOS app to php script not working... Simple solution is likey
body: <p>I have done this several times before but for some reason I can't get the post to go through... I tried the php script with the variables set to _POST and without... When they aren't set to post it works fine. Here is my iOS code:</p>
  
  <pre><code>NSDate *workingTill = timePicker.date;
  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  [formatter setDateFormat:@"HH:mm"];
  NSString *time = [formatter stringFromDate:workingTill];
  
  NSString *post = [NSString stringWithFormat:@"shift=%@&amp;username=%@", time, usernameString];
  
  NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
  NSString *postLength = [NSString stringWithFormat:@"%d", [post length]];
  
  NSURL *url = [NSURL URLWithString:@"http://wowow.php"];
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
  [request setHTTPMethod:@"POST"];
  NSLog(@"%@", post);
  [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
  [request setHTTPBody:postData];
  
  [NSURLConnection connectionWithRequest:request delegate:nil];
  
  [self.navigationController popToRootViewControllerAnimated:YES];
  </code></pre>
  
  <p>And here is a chunk of the php, are the POST variables not in the right location? </p>
  
  <pre><code>&lt;?php
  function objectsIntoArray($arrObjData, $arrSkipIndices = array())
  {
      $arrData = array();
  
      // if input is object, convert into array
      if (is_object($arrObjData)) {
          $arrObjData = get_object_vars($arrObjData);
      }
  
      if (is_array($arrObjData)) {
          foreach ($arrObjData as $index =&gt; $value) {
              if (is_object($value) || is_array($value)) {
                  $value = objectsIntoArray($value, $arrSkipIndices); // recursive call
              }
              if (in_array($index, $arrSkipIndices)) {
                  continue;
              }
              $arrData[$index] = $value;
          }
      }
      return $arrData;
  }
  
      $newShift = $_POST('shift');
      $bartenderUsername = $_POST('username');
  
      mysql_connect("host", "name", "pw") or die(mysql_error());  
      mysql_select_db("harring4") or die(mysql_error());
  
      $result = mysql_query("SELECT * FROM BartenderTable WHERE username='".$bartenderUsername."'") or die(mysql_error());  
  
      $row = mysql_fetch_array($result);
      $newfname = $row['fname'];
  </code></pre>
  
  <p>I imagine this is a rather simple answer to a more experience developer, thanks for your help!</p>