I post an INSERT sql statement from my App (Xcode - swift) to the database (MySql) on web server.
When I use it with table have auto increment feature it insert 2 rows with same data fields, but when i use it with another table (not have auto increment) it works fine!
also, i tried to post the connection string direct to the browser to see if there is any problem in my PHP file but t works fine!
The problem just happened when i use my PHP file via Xcode
any idea to fix this?
The code:
var urlString: NSString = "\(host)/(my PHP file name).php?stm=\(finalStatment)&user=\(user)&pass=\(password)&dbname=\(dbName)&mode=\(mode)"
var url = NSURL(string: urlString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
var urlRequest: NSMutableURLRequest = NSMutableURLRequest()
urlRequest.URL = NSURL(string: urlString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
urlRequest.HTTPMethod = "POST"
var con:NSURLConnection = NSURLConnection(request: urlRequest, delegate:self)!
var urlData = NSData(contentsOfURL: url!)