my java function

我的java函数

private void adddataintophp(String title, String date, String time, String channel){
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    //http post
    try{
        nameValuePairs.add(new BasicNameValuePair("Title", title));
        nameValuePairs.add(new BasicNameValuePair("Date", date));
        nameValuePairs.add(new BasicNameValuePair("Time", time));
        nameValuePairs.add(new BasicNameValuePair("Channel", channel));
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://10.0.2.2/insertprogram.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
    }catch(Exception e){
        Log.e("log_tag", "Error in http connection"+e.toString());
    }
}

my php code

我的PHP代码

<?php
$title = $_POST['Title'];
$date = $_POST['Date'];
$time = $_POST['Time'];
$channel = $_POST['Channel'];
mysql_connect("localhost","root","");
mysql_select_db("imammuda");
$sql=mysql_query("insert into Program (ID, Title, Date, Time, Channel) values ('NULL', '$title', '$date', '$time', '$channel')");
mysql_close();
?>

when i execute it, then i go database there and see.

当我执行它,然后我去那里的数据库,看看。

It was added but with null value.

它被添加但具有空值。

So, my question is how to pass the value that get by edittext in java into php

所以,我的问题是如何将java中的edittext获取的值传递给php

2 个解决方案

#1


0

You're doing a POST request from within Java, but read the GET request inside your PHP code. When posting your data, it won't show up in the URL, where the data should be according to the GET verb.

您正在从Java中执行POST请求,但是在PHP代码中读取GET请求。发布数据时,它不会显示在URL中,其中数据应根据GET动词。

更多相关文章

  1. 纯真ip数据库查询的php实现(补充分组查询)
  2. 添加到数据库后,保持在同一页面而不刷新它
  3. 在Web Page中包含PHP代码
  4. PHP 导出 万级别数据 时间测试
  5. 数据库是存储我的Web应用程序数据的最佳选择吗?
  6. php执行数据库查询返回json格式数据
  7. PHP更新基于其他表的表数据
  8. 解决PHP导出大量数据时设置超链接的问题
  9. 如何用jQuery AJAX调用发送所有当前的post数据

随机推荐

  1. Android 获取网络图片
  2. Android SharedPreferences本地缓存
  3. 如何开始使用Android应用程序模板
  4. iphone、android的mimetype
  5. Android 富文本编辑器 - ListItemSpan
  6. 【Android】AsyncTask 实现登陆
  7. Android编译相关
  8. Android working with Volley Library
  9. 通过设置android:imeOptions来改变软键盘
  10. Android 5.0.1 Layout_toLeftOf不生效