我正在尝试将数据从我的android发送到我的sql server
这是我的Android应用程序
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("firstName",value));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
这是我的php
$firstName = $_POST["firstName"];
$sql = "SELECT firstName FROM `colleague` WHERE `lastName`
LIKE '%$firstName%' LIMIT 0, 5 ";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) $output[] = $row['firstName'];
echo implode("<br/>",$output);
print(json_encode($output));
但现在选择前五行..它在$ firstName = $ _POST [“firstName”]中没有收到任何内容。 ??
php Notice
Undefined index: firstName in C:\xampp\htdocs\
http声明
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.1/Search.php");
答案 0 :(得分:0)
$firstName = $_POST['firstName'];
尝试单引号。 $ firstName的值是否有空格?如果它是编码的,请在PHP中解码。例如,如果您有Your(space)Name
,则编码形式将为Your+Name
,如果您不解码,则查询具有$firstName
的编码值。使用urldecode($_POST['firstName'])
解码已编码的网址内容