0

I am trying to update my database field with some value with respect to value send from edit text values ... My code is:

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();
           }
     }
});

My php code:

 <?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);
?>

Whenever I'm trying to click on my confirm button its giving this error .. enter image description here

I'm not getting where actually is my error. PLs hlp me. Thnx in advance.

priya89
  • 77
  • 10

1 Answers1

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); 
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213