我正在尝试从 to 发送所有值edittext
,database
但所有数据都完美地添加到其中,database
但 date
它显示的字段是0000-00-00
我的代码:
public class ProposeMeeting1Activity extends Activity
{
TextView txtview,textview,eorg;
Button bthm,btnsnd;
String pdate,ptime,pvenue,uid,cdate;
HttpPost post;
HttpResponse res;
HttpClient client;
InputStream in;
StringBuffer sb;
Date date1;
String str;
int ch;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_propose_meeting1);
Intent intent = getIntent();
pdate = intent.getStringExtra("sdate");
ptime = intent.getStringExtra("stime");
pvenue = intent.getStringExtra("svenue");
uid=intent.getStringExtra("uid");
bthm= (Button)findViewById(R.id.button2);
eorg = (TextView)findViewById(R.id.textView8);
eorg.setText(uid);
btnsnd= (Button)findViewById(R.id.button1);
btnsnd.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
try {
List<NameValuePair>parameters= new ArrayList<NameValuePair>(2);
parameters.add(new BasicNameValuePair("organiser",eorg.getText().toString()));
parameters.add(new BasicNameValuePair("attendees",einvite.getText().toString()));
parameters.add(new BasicNameValuePair("title",etitle.getText().toString()));
parameters.add(new BasicNameValuePair("mdate",edate.getText().toString()));
parameters.add(new BasicNameValuePair("mtime",etime.getText().toString()));
parameters.add(new BasicNameValuePair("venue",evenue.getText().toString()));
post=new HttpPost("http://10.0.2.2/meetingschedular/sendinvite.php");
post.setEntity(new UrlEncodedFormEntity(parameters));
client= new DefaultHttpClient();
res=client.execute(post);
HttpEntity en=res.getEntity();
in=en.getContent();
sb=new StringBuffer();
while((ch=in.read())!=-1){
sb.append((char)ch);
}
str=sb.toString();
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_LONG).show();
einvite.setText("");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
我的php代码如下:
`<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('meetingschedulardata',$con);
if(!$con)
{
die("can not connect".mysql_error());
}
$order="INSERT INTO meetingdetails (organiser,attendees,title,mdate,mtime,venue) values('$_POST[organiser]','$_POST[attendees]','$_POST[title]','$_POST[mdate]','$_POST[mtime]','$_POST[venue]')";
$result=mysql_query($order,$con);
if($result==1)
{
echo "Want To Invite More Then Continue";
}
else
{
echo "Problem occurs while Invitingm".mysql_error();
}
?>`