<?php
$title = $_POST['title'];
$date = $_POST['date'];
$time = $_POST['time'];
$channel = $_POST['channel'];
mysql_connect("localhost","root","");
mysql_select_db("imammuda");
$sql=mysql_query("insert into Program (ID, Title, Date, Time, Channel) values ('NULL', $title, $date, $time, $channel);
mysql_close();
?>
这是我的POST运行PHP时插入数据为什么会出现意想不到的错误?
private void adddataintophp(String title, String date, String time, String channel){
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//http post
try{
nameValuePairs.add(new BasicNameValuePair("title", title));
nameValuePairs.add(new BasicNameValuePair("date", date));
nameValuePairs.add(new BasicNameValuePair("time", time));
nameValuePairs.add(new BasicNameValuePair("channel", channel));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/insertprogram.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
}
,它给了我
Parse error: syntax error, unexpected $end in C:\wamp\www\InsertProgram.php on line 10
我不知道为什么就不能结束。
请帮助我在邮政那里,我认为有一些错误,我没有找到它。
正如您在语法高亮显示中看到的那样,您缺少一个引号,请确保您使用的IDE或编辑器的语法突出显示 – 2011-05-19 10:00:41
@Pekka - 甚至是SO的语法高亮显示它。 - ) – 2011-05-19 10:05:47