我有以下代码链接到一个 PHP 文件,目的是发布一些字符串并在 PHP 文件中检索,所有的东西都工作正常,但我的代码有问题,见下文:
iOS 应用程序代码
NSString *urlString = @"http://www.myurl.com/path/ios.st.addquestion.php?";
NSURL *uploadURL = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:uploadURL];
[request setPostValue:askerUsername forKey:@"username"];
[request setPostValue:@"1" forKey:@"questiontype"];
[request setPostValue:title forKey:@"title"];
[request setPostValue:hasAditional forKey:@"hasaditional"];
[request setPostValue:aditional forKey:@"aditional"];
[request setPostValue:hasLocation forKey:@"haslocation"];
[request setPostValue:location forKey:@"location"];
[request setPostValue:latitude forKey:@"latitude"];
[request setPostValue:longitude forKey:@"longitude"];
[request setPostValue:category forKey:@"category"];
[request setPostValue:hasImage forKey:@"hasimage"];
[request startAsynchronous];
PHP 文件
$questiontype = mysql_real_escape_string($_GET['questiontype']);
$username_PRO = mysql_real_escape_string($_GET['username']);
$title_PRO = mysql_real_escape_string($_GET['title']);
$hasAditional = mysql_real_escape_string($_GET['hasaditional']);
$aditional_PRO = mysql_real_escape_string($_GET['aditional']);
$hasLocation = mysql_real_escape_string($_GET['haslocation']);
$location_PRO = mysql_real_escape_string($_GET['location']);
$latitude_PRO = mysql_real_escape_string($_GET['latitude']);
$longitude_PRO = mysql_real_escape_string($_GET['longitude']);
$category = mysql_real_escape_string($_GET['category']);
echo "$username_PRO";
当我运行应用程序并将字符串 POST 到 PHP 文件时,什么都没有发生,就像 PHP 收到一个空值一样,我无法弄清楚我的代码有什么问题,有人知道吗?过程是这样的:
Application => ASIFormDataRequest(Post values) => PHP 文件接收请求并在 MYSQL 数据库中插入字符串(问题在这里)。
我已经在网上和 ASI 网站上搜索过,但似乎没有任何效果。