Reputation: 123
i have an app which needs to send data to mysql to insert into my tables. So I am using PHP to achieve this. But the problem is that I am not able to send data with spaces in between. How can I achieve this? Do I need to encode the data in xml/JSON or is there any other way? If I need to encode the data..how should I do it?
Any help is appreciated.
PHP code:
$guesttype = $_GET["guesttype"];
$guestLname =$_GET["guestLname"];
$guestFname =$_GET["guestFname"];
----
echo "something";
OBJECTIVE C CODE:
NSString *strURL = [NSString stringWithFormat:PHPurlwithargs ,userName, password, hostName, DBName, function, userCompany, _todisplaytype];
// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
// to receive the returend value
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
Upvotes: 0
Views: 591
Reputation: 119
JSON encode your data in objective-c before sending it over to your PHP block. That should take care of any spaces that may be passed along as well.
ie. NSString* stringData = [[NSString alloc] initWithData:yourData encoding:NSUTF8StringEncoding];
Upvotes: 1