我正在尝试更新数据库中的字段,但是从我的php页面获取未定义的变量错误...
我的代码是:
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);
fdate=cdate.getText().toString();
ftime=ctime.getText().toString();
ftitle=title.getText().toString();
fvenue=venue.getText().toString();
fattend=uid.toString();
cnfrm=(Button)findViewById(R.id.button1);
cnfrm.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try
{
String str_params=URLEncoder.encode("res="+resy.toString()+
"&title="+ftitle+
"&venue="+fvenue+
"&cdate="+fdate+
"&ctime="+ftime+
"&attend="+fattend,"UTF-8");
get= new HttpGet("http://10.0.2.2/meetingschedular/confirmmeet.php?"+str_params);
client= new DefaultHttpClient();
res=client.execute(get);
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);
Toast.makeText(getApplicationContext(), tmp, Toast.LENGTH_LONG).show();
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
// Connects to your Database
$con=mysql_connect('localhost','root','');
mysql_select_db('meetingschedulardata',$con);
if(!$con)
{
die("can not connect".mysql_error());
}
if (isset($_GET['title']))
{
$title=$_GET['title'];
}
if(isset($_GET['cdate']))
{
$cdate=$_GET['cdate'];
}
if(isset($_GET['ctime']))
{
$ctime=$_GET['ctime'];
}
if(isset($_GET['attend']))
{
$attend=$_GET['attend'];
}
if(isset($_GET['venue']))
{
$venue=$_GET['venue'];
}
if(isset($_GET['res']))
{
$res=$_GET['res'];
}
$sdate = strtotime($cdate);
$new_date = date('Y-m-d', $sdate);
$stime = strtotime($ctime);
$new_time = date('h:i:s', $stime);
//echo "till now it works..";
$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);
//echo "It still works";
if($result==1)
{
echo "true";
}
else{
echo "false".mysql_error();
}
mysql_close($con);
?>
我想更新我的数据库中的状态字段但无法执行此操作.. 它显示的错误就像这样
请告诉我一些事情,以便我可以正确运行我的应用程序...... Thnx提前
答案 0 :(得分:0)
检查你从android传递的变量以及你在php代码中在服务器端使用的变量。 使用print_r($ _ REQUEST)从php端检查它;出口;在页面的开头。 这将帮助您调试,你可以从android传递变量列表。
如果您从中得到所有精细且相同的变量,那么在服务器端您将没有问题。
谢谢:) Kuldip