I want to send some string text data from my iphone to the server. I am using a php file on my server. The php works fine if i use it on the webpage but only sends one word if there are 2 words nothing will be send like the connection does not exist.
PHP:
if (isset ($_GET["vic"]))
$name = $_GET["vic"];
else
$name = "empty text";
$con = mysql_connect('sqlserver', 'username', 'pasword');
if (!$con) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db(db_name);
$sql = "insert into Vici (VIC) values('$name');";
$res = mysql_query($sql,$con) or die(mysql_error());
mysql_close($con);
?>
iOS:
- (IBAction)add
{
NSString *vic = txtVic.text;
NSString *strURL = [NSString stringWithFormat:@"%@%@",@"http://URL",vic];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
NSString *povezava = @"Connected successfully ";
if([povezava isEqualToString:strResult])
izpis.text = @"added";
}
I did not use any real info because its private. Than you.