0

项目id_category没有发送到服务器,但其他项目发送没有问题。

添加.php:

<?php
header("Content-Type: text/html;charset=utf-8");
require_once('../php/mysql_conect.php');
$use_db=mysql_query("use open_service;");

$date=date("Y-m-d");
$time=date("H:i:s");

$insert=mysql_query("insert into records(id_category,name,phone,device_id,address,text,publish_date,publish_time) value('$_POST[id_categoty]','$_POST[name]','$_POST[phone]','$_POST[device_id]','$_POST[address]','$_POST[text]','$date','$time');");
?>

我的部分代码:

//获取id设备

       *TelephonyManager telMgr=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
       String device_id = telMgr.getDeviceId().toString();


       name_post = name.getText().toString();
       phone_post=phone.getText().toString();
       address_post=address.getText().toString();
       comment_post=comment.getText().toString();
       String id_category="1";

    // Create a new HttpClient and Post Header
                    HttpClient httpclient = new DefaultHttpClient();
                    httpclient.getParams().setParameter("http.protocol.version",

HttpVersion.HTTP_1_1); httpclient.getParams().setParameter("http.socket.timeout", new Integer(2000)); httpclient.getParams().setParameter("http.protocol.content-charset", "UTF-8"); HttpPost httppost = new HttpPost("http://10.100.100.20/test/mobile/add.php");

                    try {
                            // Add your data
                            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6);
                            nameValuePairs.add(new BasicNameValuePair("name", name_post));
                            nameValuePairs.add(new BasicNameValuePair("phone", phone_post));
                            nameValuePairs.add(new BasicNameValuePair("address", address_post));
                            nameValuePairs.add(new BasicNameValuePair("text", comment_post));
                            nameValuePairs.add(new BasicNameValuePair("device_id", device_id));
                            nameValuePairs.add(new BasicNameValuePair("id_category", id_category));<--It's don send to

服务器 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));

                            response = httpclient.execute(httppost);
               //Создаем уведомление
            Toast toast=Toast.makeText(getBaseContext(), "Заявка успешно отправлена", Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, -200);
            toast.show();

            //Возвращаемся а предыдущие Activity
             Intent intent= new Intent();
             intent.setClass(getApplicationContext(), EservisActivity.class);
             startActivity(intent);

                    }*
4

1 回答 1

0

add.php:$_POST[id_categoty]而不是$_POST[id_category]

于 2012-05-31T12:19:07.967 回答