doumiebiao6827 2016-03-14 11:47
浏览 36

通过HTTP链接从UITextField发送UTF8字符串

I'm using php method as web service to add user_comment to mysql database.

 <?php 
    require '../database/connection.php'; 
    extract($_POST);

    if (isset($_GET['book_ID'])) {

        $book_ID = $_GET['book_ID'];
        $user_ID = $_GET['user_ID'];
        $theComment = $_GET['theComment'];
    }

if (!$db) {

    $json[] = array("Message" => "Connection failed");
    echo json_encode($json);
}

$sql = mysql_query("INSERT INTO Comment (user_ID , book_ID , theComment) VALUES ('$user_ID','$book_ID','$theComment')");
mysql_query($sql, $db);

$json[] = array("Message" => "Done");
echo json_encode($json);

everything fine if I type English but I have problem with Arabic

Objective-C:

-(NSString *)addCommentForBook:(NSString *)bookID userID:(NSString *)userID theComment:(NSString *)theComment{
    NSString *dt = [NSString stringWithFormat:@"?book_ID=%@&user_ID=%@&theComment=%@",bookID,userID,theComment];
    NSURL *myURL = [[NSURL alloc]initWithString:[NSString stringWithFormat:@"http://www.myweb.com/library/Books/addCommentForBook.php%@",dt]];
    NSMutableDictionary *theArray;
    NSData *myData = [[NSData alloc]initWithContentsOfURL:myURL];

    if (myData) {
        id myJSON = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:nil];
        theArray = (NSMutableDictionary *)myJSON;
    }

    return [[theArray valueForKey:@"Message"]objectAtIndex:0];
}

If I test from Browser work php work fine with Arabic but from iOS not work

Any one tell me what's wrong or do I need to convert the string from UITextField first or?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端