Android uygulaması PHP script veri gönderir - Beklenti başarısız oldu

0 Cevap php

I try to develop an app which needs to send data to a MySql database. In order to achieve it, I create a httppost as follows

public void postData() {    
     try {
       // Create a new HttpClient and Post Header 
      HttpClient httpclient = new DefaultHttpClient();  
      HttpPost httppost = new HttpPost("myscript.php");  
   // Add your data 
         List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
         nameValuePairs.add(new BasicNameValuePair("name", "Noon"));  
         nameValuePairs.add(new BasicNameValuePair("level", "0"));  
         httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  

         // Execute HTTP Post Request  
         HttpResponse response = httpclient.execute(httppost);           
         String text = EntityUtils.toString(response.getEntity());          
            Log.i("","response = "+text); 
     } catch (ClientProtocolException e) {  
         // TODO Auto-generated catch block 
      e.printStackTrace();
     } catch (IOException e) {  
         // TODO Auto-generated catch block  
      e.printStackTrace();
     }  
 }   

Benim sunucuda, ben şu script var:

<?php
$link = mysql_connect("localhost", "user", "password")
    or die("Impossible de se connecter : " . mysql_error());
echo 'Connected';

$db_selected = mysql_select_db('db', $link);
if (!$db_selected) {
   die ('Impossible de sélectionner la base de données : ' . mysql_error());
}
mysql_query("INSERT INTO players (name, level) VALUES ('".$_REQUEST['name']."', '".$_REQUEST['level']."')");
mysql_close($link);
?>

String text hata 417 ile doludur - beklenti başarısız oldu.

I understand the problem but does not understand how to fix it. I would appreciate your help on this issue as I am a bit stuck.

0 Cevap