2013-05-02 101 views
0

我試圖更新我的數據庫字段相對於價值的一些價值從編輯文本值發送... 我的代碼是:非法參數異常70

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

每當我試圖點擊我的確認按鈕,它給這個錯誤.. enter image description here

我沒有收到哪裏實際上是我的錯誤。 PLs hlp我。 Thnx提前。

+0

StackTrace?哪裏有錯誤? – NINCOMPOOP 2013-05-02 08:03:17

+0

向我們展示您的查詢打印請 – 2013-05-02 08:07:23

+0

我dint得到你的問題哪些查詢你想看..我已經給我的php代碼以及java代碼..我不geetinh你究竟想要什麼@ZouZou – priya89 2013-05-02 08:13:57

回答

2

在日誌中:

拋出:IllegalArgumentException:在查詢非法字符

意味着要傳遞錯誤的字符查詢字符串中使用URL。使用URLEncoder.encode進行請求前的編碼參數。它可以:

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); 
+0

它工作thnx很多...... :) – priya89 2013-05-02 08:29:26

+0

@ priya89:最受歡迎的朋友 – 2013-05-02 08:38:32