title: getting Error Domain=NSCocoaErrorDomain Code=3840 "No value."
body: <p>I am getting this error when i try to insert data in my SQL database through php in swift</p>
  
  <p>I'm not sure why i'm getting this error. I'm new to swift and really stuck on this situation</p>
  
  <p>error im getting: </p>
  
  <pre><code>  Error Domain=NSCocoaErrorDomain Code=3840 "No value." 
   UserInfo={NSDebugDescription=No value.}
  </code></pre>
  
  <p>here is my swift code</p>
  
  <pre><code>     let myURL = NSURL(string: "http://localhost:8888/userRegister.php");
          let request =   NSMutableURLRequest(URL: myURL!);
          request.HTTPMethod = "POST";
  
          let postString = "email=\(username)&amp;password=\(password)&amp;firstName=\(firstName)"
  
          print(postString)
  
  
          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: .MutableContainers) as? NSDictionary
                  if let parseJSON = json{
                      let resultValue = parseJSON["status"] as! String!
                      print("result:\(resultValue)")
  
                      var isUserRegistered: Bool = false;
                      if(resultValue == "success"){
                          isUserRegistered = true;
                      }
                      var messageToDisplay:String = parseJSON["message"] as! String!;
                      if (!isUserRegistered)
                      {
                          messageToDisplay = parseJSON["message"] as! String!;
                      }
  
                      dispatch_async(dispatch_get_main_queue(), {
                          let myAlert = UIAlertController(title: "Alert", message: messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert);
                          let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default){ action in
  
                              self.dismissViewControllerAnimated(true, completion: nil);
                          };
  
                          myAlert.addAction(okAction);
                          self.presentViewController(myAlert, animated: true, completion: nil);
                          }
  
  
                      )};
  
  
              } catch { print(error)}
          }
  
          task.resume();
  </code></pre>
  
  <p>and my php:</p>
  
  <pre><code>$email = htmlentities($_POST["email"]);
  $password = htmlentities($_POST["password"]);
  $firstName = htmlentities($_POST["firstName"]);§
  
  $result = $dao-&gt;registerUser($email,$secure_password,$firstName);
  
  if($result) 
  {
  $returnValue["status"] = "Success";
  $returnValue["message"] = "User is registered";
  echo json_encode($returnValue);
  return; 
  }
  
  public function registerUser($email, $password, $firstName)
  {
  $sql = "insert into users set username=?, password=?,firstName=?";
  $statement = $this-&gt;conn-&gt;prepare($sql);
  
  if (!$statement)
  throw new Exception($statement-&gt;error);
  
  $statement-&gt;bind_param("sss", $email, $password, $firstName);
  $returnValue = $statement-&gt;execute();
  
  return $returnValue;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thank you in advance</p>