0
我想用php發送一些東西給mysql,但是,swift似乎沒有發送我想要的信息,並且我使用php ,最後我發現它的符號「+」導致問題,我該如何解決這個問題?是因爲swf utf8編碼問題?請指教。Swift 3.0 - 無法通過PHP發送「加」(+)到mySQL通過PHP
func LoadDataToServer(){
let request = NSMutableURLRequest(url: NSURL(string:"<myphpaddress>.php")! as 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 as 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()
}