I have a simple php page that takes as argument, via GET, some parameters. These parameters represent a string value to put in a database online and a condition: if it had to be inserted or deleted (parameter insert=1 then insert, parameter delete=1 then delete). The page gets called in this way:
http://www.example.com/save_string.php?string=6&insert=1 OR http://www.example.com/save_string.php?string=6&delete=1
When i call it by my browser it works perfectly. When i call it by my ios app i see a strange behaviour. It happens if i call, even in separate moments of time but sequentially:
http://www.example.com/save_string.php?string=6&insert=1 OK
http://www.example.com/save_string.php?string=6&delete=1 OK
http://www.example.com/save_string.php?string=6&insert=1 NOT WORKING
I mean, if i call it to insert a value, it works perfectly. Then if i call it to delete the same value, it works perfectly. Then i if i call it to insert the same value i deleted it doesn't insert it anymore. Not even if i call it a thousand times. But if i get back to my pc and my browser and i call the url ios is calling again and again with no result, it works perfectly. I hope i explained myself for it is so nonsense to me that i can't do better. Here's my php and objective C code, pretty simply really.
string.php
<?php
$string=$_GET['string'];
$insert=$_GET['insert'];
$delete=$_GET['delete'];
if($insert){
$qry = "INSERT INTO SOMETABLE (SOMEFIELD) VALUES (".$string.")";
}
if($delete){
$qry = "DELETE FROM SOMETABLE";
}
$rs = connetti($qry);
?>
Ios code
NSString *urlString = @"http://www.example.com/save_string.php?string=6&insert=1";
NSString *escapedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *urlLink = [NSURL URLWithString:escapedString];
NSLog(@"!%@!",urlLink);
NSURLRequest *request = [NSURLRequest requestWithURL: urlLink cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];