0

我有以下问题...我正在构建一个 android 应用程序,并且我使用 POST 方法从 editTexts 中重新获取以 utf8(希腊字符)格式的文本。POST 方法从 editTexts 获取希腊字符为 '???' 并再次将它们插入 mysal 为'???' POST 将如何识别我的希腊字符???

<?php
// PHP variable to store the host address
 $db_host  = "localhost";
 // PHP variable to store the username
 $db_uid  = "lolen";
 // PHP variable to store the password
 $db_pass = "lolen";
 // PHP variable to store the Database name  
 $db_name  = "lolen"; 
        // PHP variable to store the result of the PHP function 'mysql_connect()' which establishes the PHP & MySQL connection  
 $db_con = mysql_connect($db_host,$db_uid,$db_pass) or die('could not connect');

   mysql_query("SET character_set_results=utf8", $db_con);
    mb_language('uni'); 
    mb_internal_encoding('UTF-8');
    mysql_select_db($db_name, $db_con);
    mysql_query("set names 'utf8'",$db_con);

// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['k_p']) ) 
{
$Kwdikos_Proiontos=$_POST['k_p'];
$Proion=$_POST['p'];
$Kwdikos_Tupou=$_POST['k_t'];
//$Tupos=$_POST['t'];
$sql=mysql_query("SELECT * FROM tupoi WHERE Kwdikos_Tupou LIKE '". $_POST["k_t"]."'", $db_con);
while($row = mysql_fetch_array($sql))
  {
$output[]=$row['Tupos'];
$re= json_encode($output[0]);
$dd= json_decode($re, true);
  }
$result =mysql_query("INSERT INTO proionta(Kwdikos_Proiontos, Proion, Kwdikos_Tupou, Tupos) VALUES('$Kwdikos_Proiontos', '$Proion', '$Kwdikos_Tupou', '$dd')");
 //check if row inserted or not
    if ($result) {
        // successfully inserted into database
       $response["success"] = 1;
        $response["message"] = "Product successfully created.";

        // echoing JSON response
        echo json_encode($response);
    } 
    else    {
        // failed to insert row     
        $response["success"] = 0;
        $response["message"] = "Oops! An error occurred.";

        // echoing JSON response
       echo json_encode($response);
    }
}
 else 
{
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";

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

附言。我的数据库已经在 utf8 中,因为我通过在数据库中使用 SELECT、INSERT 以希腊语显示和添加其他数据。

4

1 回答 1

0

最后我找到了解决问题的方法,我使用了 GET 方法而不是 POST,现在它可以正常工作了!Thnx 对于 sql 注入技巧,我将阅读更多关于这个问题的信息!

于 2013-08-21T15:16:27.567 回答