Swift 3.0 - Couldn't Send "plus" (+) to mySQL through PHP -


i sent mysql using php, however, swift seem failed sent information want, , traced problem using php, , found symbol "+" causing problem, how gonna solve problem? because swift utf8 encoding problem? please advise.

func loaddatatoserver(){ let request = nsmutableurlrequest(url: nsurl(string:"<myphpaddress>.php")! url) request.httpmethod = "post" let poststring = "tag=newcustomer&ap_contact_no=+12345678&cpm_no=123331231"  request.httpbody = poststring.data(using: string.encoding.utf8) let task = urlsession.shared.datatask(with: request urlrequest) { (data, response, error) in      if (error != nil)     {         print("error =\(error)")         return     }     else     {         print("response\(response)")         let responsestring = nsstring(data: data!, encoding: string.encoding.utf8.rawvalue)         print(responsestring ?? "error")     } } task.resume() 

}

+ 1 of reserved character in urls, ?, &, =, , on. equivalent of space character. if need have plus sign in url, need encode %2b.

read more: https://en.wikipedia.org/wiki/percent-encoding


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -