0

My php file :

if(isset($_POST['eposta'])&&isset($_POST['sifre']))//uygulamadan gelen verileri kontrol etme
{
    $eposta = $_POST['eposta'];//gelen eposta yı alma
    $sifre = $_POST['sifre'];//gelen sifreyi alma
    require("ayar.php");//Ayar dosyasını içe aktarma
    $sorgu = mysql_query("Select * From Kullanici Where Eposta='$eposta' AND Sifre='$sifre'");//gelen sifre ve epostayı kontrol etme
    header("Content-type: application/json");//JSON Tipi yapma
    if($oku = mysql_fetch_array($sorgu))//gelen sifre ve epostayı kontrol etme
    {
        $data[] = array(
            "islem" => true
        );
    }
    else
    {
        $data[] = array(
            "islem" => false
        );
    }
    echo json_encode($data);
}

My android file :

HttpPost post = new HttpPost("http://www.tutaret.tk/not/mobil_giris.php");

List<NameValuePair> gonderilenler = new ArrayList<NameValuePair>(2);

gonderilenler.add(new BasicNameValuePair("eposta",eposta.getText().toString()));

gonderilenler.add(new BasicNameValuePair("sifre",sifre.getText().toString()));

post.setEntity(new UrlEncodedFormEntity(gonderilenler,"UTF_8"));

HttpResponse response = client.execute(post);

if(response!=null)

{

InputStream in = response.getEntity().getContent();

BufferedReader oku = new BufferedReader(new InputStreamReader(in));

StringBuilder kodlar = new StringBuilder();

String satir;

while ((satir = oku.readLine())!=null)//döngü ile sayfadaki kodları alma

{

kodlar.append( satir+"\n");//Satir satır kodları ekleme

}

Log.e("HTML",kodlar.toString());

JSONArray json_dizi = new JSONArray(kodlar.toString());

And I have this error on logcat :

04-20 15:58:41.233 2598-23393/com.not.tuncozer.not E/Error!: Value  of type java.lang.String cannot be converted to JSONObject
Marc B
  • 356,200
  • 43
  • 426
  • 500
  • 2
    You're using a database API that has been unsupported for more than 5 years; those `mysql_*` functions don't even exist in current PHP. [Stop using them!](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – miken32 Apr 20 '16 at 16:03
  • Also if you want any help you'll need to format your code and provide a clear explanation of what your problem is. – miken32 Apr 20 '16 at 16:03
  • But it is working for now and this error don't related with mysql_* –  Apr 20 '16 at 16:04
  • You are vulnerable to [sql injection attack](http://bobby-tables.com). – Marc B Apr 20 '16 at 16:05
  • miken32 I making a login window on android and i check email and password from web database. İf password is true php writes to page [{"islem":true}] . And I convert this string to json array . But i have error –  Apr 20 '16 at 16:24
  • What is the output of your line `Log.e("HTML".kodlar.toString())` – Jose Rojas Apr 20 '16 at 16:53
  • Jose Rojas : 04-20 16:44:54.331 2598-30715/com.not.tuncozer.not E/HTML: [{"islem":true}] –  Apr 20 '16 at 16:55
  • at the server side there is no problem, I think is the client side in your JavaFile, maybe this can help you: http://stackoverflow.com/questions/14812560/how-to-parse-the-json-response-in-android – Jose Rojas Apr 20 '16 at 17:06
  • Jose Rojas I can't take as JSONObject , too . It gives same error –  Apr 20 '16 at 17:09

0 Answers0