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
.
Comments
Post a Comment