php - Android 到 MySQL 土耳其语字符写入为 "?"

标签 php android mysql

当我获取 EditText 的文本并将其写入 MySQL 数据库时,土耳其语字符将作为“?”进入数据库。奇怪的部分是“ö,ü,ç”很好。问题是“ı”和“ğ”。当我直接输入它们时也可以。我的问题是在 Android 部分还是 PHP 部分,还是其他方面?

        <?php



    // array for JSON response
    $response = array();

    // check for required fields
    if (isset($_POST['AdayTC'])) {

       $AdayTC = $_POST['AdayTC'];
       $OzGecmis = $_POST['OzGecmis'];
       $Projeleri = $_POST['Projeleri'];

       // include db connect class
        require_once __DIR__ . '/db_connect.php';

        // connecting to db
        $db = new DB_CONNECT();

        $basvuruKontrol = mysql_query("SELECT AdayTC FROM adaybasvurusu WHERE AdayTC = '$AdayTC'");
    if(mysql_num_rows($basvuruKontrol) == 0) {
                    $result = mysql_query("INSERT INTO adaybasvurusu (AdayTC, OzGecmis, Projeleri, Onay) VALUES ('$AdayTC', '$OzGecmis', '$Projeleri',0)");
                        $response["success"] = 1;
                        $response["message"] = "Basvuru Gonderildi";

                        // echoing JSON response
                        echo json_encode($response);
                    } else {
                    // failed to insert row
                        $response["success"] = 0;
                        $response["message"] = "Zaten Basvuru Yapilmis";

                        // echoing JSON response
                        echo json_encode($response);
                            }

    } else {
        // required field is missing
        $response["success"] = 0;
        $response["message"] = "Gerekli Alanlar Eksik";

        // echoing JSON response
        echo json_encode($response);
    }
    ?>

编辑:

我尝试添加 mysql_error() 函数:

 echo mysql_errno($result) . ": " . mysql_error($result) . "\n";

...现在我在错误日志中看到了这个:

 [03-Jan-2014 11:43:00 UTC] PHP Parse error:  syntax error, unexpected T_ECHO in /home/xxx/public_html/xxx/adaybasvuru.php on line 29

第29行是我添加echo mysql_error函数的行。

最佳答案

问题似乎出在 JSONParser 类上,这样我就能够解决我的问题。

if(method == "POST"){
                // request method is POST
                // defaultHttpClient
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);
                StringEntity entity = new UrlEncodedFormEntity(params,"latin5");
                httpPost.setEntity(entity);


                HttpResponse httpResponse = httpClient.execute(httpPost);
                HttpEntity httpEntity = httpResponse.getEntity();
                is = httpEntity.getContent();

            }

关于php - Android 到 MySQL 土耳其语字符写入为 "?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20887072/

相关文章:

php - 为特定子域设置 session cookie

php - 为什么 PHP $_SERVER 变量中的 HTTP 响应代码不可用?

php - 有没有更好的方法来为多插入返回最后插入的 ID?

mysql - 尝试制作 Django/Mezzanine "Page last updated by on date"

php - mysql_query 不工作

php - MySQL:查询搜索所有可能的单词

java - 毕加索图片在 android 中加载缓慢,为什么?

java - 使用 Android 和 Libgdx 构建时出现意外的顶级异常错误

android - AVD 管理器 - 无法创建 Android 虚拟设备

mysql - asp.net中的mysql如何转义?