0

我有一个应用程序需要将数据发送到 mysql 以插入我的表中。所以我正在使用 PHP 来实现这一点。但问题是我无法发送中间有空格的数据。我怎样才能做到这一点?我需要在 xml/JSON 中编码数据还是有其他方法?如果我需要对数据进行编码..我应该怎么做?

任何帮助表示赞赏。

PHP代码:

$guesttype = $_GET["guesttype"];
$guestLname =$_GET["guestLname"];
$guestFname =$_GET["guestFname"];

----
echo "something";

目标C代码:

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];
4

1 回答 1

1

JSON 在将您的数据发送到您的 PHP 块之前,在 Objective-C 中对您的数据进行编码。这也应该注意可能传递的任何空间。

IE。NSString* stringData = [[NSString alloc] initWithData:yourData encoding:NSUTF8StringEncoding];

于 2013-08-01T22:27:59.947 回答