title: swift error: Code=3840 "Garbage at end."
body: <p>I have this error </p>
  
  <blockquote>
    <p>Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}</p>
  </blockquote>
  
  <p>here is my swift code:</p>
  
  <pre><code>var exercise:String = ""
  
      for value in numberOfExercisesArray{
  
          exercise = exercise + value.text! + ","
  
      }
      if exercise.characters.last == ","{
  
          exercise.removeAtIndex(exercise.endIndex.predecessor())
  
      }
  </code></pre>
  
  <p>the string i want to post (exercise) is in the this context : "bench press,5,100" 
  However I cant get this string to go through because of the error above
   Below is how i connect to my php/sql server: </p>
  
  <pre><code>   let myURL = NSURL(string: "http://localhost:8888/saveWorkout.php");
          let request = NSMutableURLRequest(URL:myURL!);
          request.HTTPMethod = "POST";
  
  
  
          let postString = "exercise=\(exercise)";
  
          request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding);
  
          let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
              data, response, error in
  
              if error != nil {
                  print("error=\(error)")
                  return
              }
  
              do{
  
                  let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as? NSDictionary
  
                  if let parseJSON = json{
                      let resultValue = parseJSON["status"] as! String!;
  
                      print("result: \(resultValue)")
  
                      if(resultValue == "Success"){
  
  
  
                          print("worked")
  
  
                      }
                      else{
  
                          print("not worked")
                      }
                  }
  
              }
              catch { print(error) }
  
          }
  
  
          task.resume();
  </code></pre>
  
  <p>How do I fix this error
  Thanks</p>