0

我正在尝试使用与从编辑文本值发送的值相关的一些值来更新我的数据库字段......我的代码是:

Intent myintent = getIntent();
//mdate = intent.getStringExtra("mdate");
//Toast.makeText(getApplicationContext(), mdate.toString(), Toast.LENGTH_LONG).show();
title=(EditText)findViewById(R.id.editText1);
Bundle extras = getIntent().getExtras();
if(extras != null){ 
    mtitle = extras.getString("title");
    stime = extras.getString("mtime");
    sdate = extras.getString("mdate");
    cvenue = extras.getString("venue");
}

title.setText(mtitle);
title.setFocusable(false);
cdate=(EditText)findViewById(R.id.editText2);
cdate.setText(sdate);
cdate.setFocusable(false);
venue=(EditText)findViewById(R.id.editText4);
venue.setText(cvenue);
venue.setFocusable(false);
ctime=(EditText)findViewById(R.id.editText3);
ctime.setText(stime);
ctime.setFocusable(false);
cnfrm=(Button)findViewById(R.id.button1);
cnfrm.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
          // TODO Auto-generated method stub
          try {
                 Toast.makeText(getApplicationContext(), "Befor", 
                         Toast.LENGTH_LONG).show();
         get= new HttpGet("http://10.0.2.2/meetingschedular/confirmmeet.php?
                       res="+resy.toString()+"&title="+title.getText().toString()+"&
                       venue="+venue.getText().toString()+"&cdate="+cdate.getText()
                       .toString()+"&ctime="+ctime.getText().toString()+"&
                       attend="+uid.toString());
                 client= new DefaultHttpClient();
                 res=client.execute(get);
         Toast.makeText(getApplicationContext(), "After res", 
                         Toast.LENGTH_LONG).show();
                 in = res.getEntity().getContent();
         StringBuffer str = new StringBuffer();
                 int ch;
                 while((ch=in.read())!=-1) {
                       str.append((char)ch);
                 }
                 String tmp=str.toString();
                 tmp=tmp.trim();
                 //txt.setText(tmp);
                 if(flag.equals(tmp)) {
                      Toast.makeText(getApplicationContext(), tmp, 
                                Toast.LENGTH_LONG).show();
                 } else {
                      Toast.makeText(getApplicationContext(), "Sorry cannot confirm", 
                              Toast.LENGTH_LONG).show();
                 }
           } catch(Exception e) {
               Toast.makeText(getApplicationContext(), e.toString(), 
                      Toast.LENGTH_LONG).show();
           }
     }
});

我的PHP代码:

 <?php 
$con=mysql_connect('localhost','root','');
mysql_select_db('meetingschedulardata',$con);
if(!$con)
{
die("can not connect".mysql_error());
}
$title=$_GET['title'];
$cdate=$_GET['cdate'];
$ctime=$_GET['ctime'];
$attend=$_GET['attend'];
$venue=$_GET['venue'];
$res=$_GET['res'];
$sdate = strtotime($cdate);
$new_date = date('Y-m-d', $sdate);
$stime = strtotime($ctime);
$new_time = date('h:i:s', $stime);
$order="Update meetingdetails SET status='$res' WHERE status IS NULL AND
         title='$title' AND mdate='$new_date' AND mtime='$new_time' AND
           attendees='$attend' AND venue='$venue'";
$result=mysql_query($order,$con);
if($result==1)
{
echo "true";
}
else{
echo "false".mysql_error();
}
mysql_close($con);
?>

每当我试图点击我的确认按钮时,它都会给出这个错误.. 在此处输入图像描述

我没有得到我的错误到底在哪里。请帮助我。提前谢谢。

4

1 回答 1

2

as in log :

IllegalArgumentException: Illegal character in query

means you are passing wrong characters in QueryString with URL. use URLEncoder.encode for encoding parameters before making request.try it as:

String str_params=URLEncoder.encode(res="+resy.toString()+
                              "&title="+title.getText().toString()+
                              "&venue="+venue.getText().toString()+
                              "&cdate="+cdate.getText().toString()+
                              "&ctime="+ctime.getText().toString()+
                              "&attend="+uid.toString(),"UTF-8");
get= new HttpGet("http://10.0.2.2/meetingschedular/confirmmeet.php?"
                                                            +str_params); 
于 2013-05-02T08:08:13.107 回答