我正在尝试更新数据库中的字段,但从我的 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);
?>
我想更新我的数据库中的状态字段但无法做到这一点。它显示的错误是这样的
请给我一些建议,以便我可以正确运行我的应用程序......提前谢谢