为什么我不能从android中获取PHP的值?

I am trying to retrieve specific values from phpmyadmin database.I want to retieve the row where to=$username from mytasksend table. But when i echo the variable i don't get any output. What am i supposed to do?

Here's my php file

<?php
mysql_connect ("localhost","root","");
mysql_select_db("taskmanager");

$username= (isset($_POST['to'])) ? $_POST['to'] : '';
$q=mysql_query("SELECT `tasksentid` FROM `mytasksend` where `to` = $username")                or die(mysql_error());

$output=array(); 
   while($e=mysql_fetch_assoc($q))
   $output[]=$e;
print (json_encode($output));
mysql_close();

?>

and here's my java file

try{
   HttpClient httpclient3 = new DefaultHttpClient();
   HttpPost httppost3 = new HttpPost("http://10.0.2.2:80/selection.php");
   ArrayList<NameValuePair>  nameValuePairs = new ArrayList<NameValuePair>();
   nameValuePairs.add(new BasicNameValuePair("to",id));
   Log.w("aaaaaaa",""+nameValuePairs);
   httppost3.setEntity(new UrlEncodedFormEntity(nameValuePairs));
   HttpResponse response = httpclient3.execute(httppost3); 
   HttpEntity entity = response.getEntity();
   is = entity.getContent();

   Log.e("log_tag", "connection success ");
}

Try wrapping the $username under single quotes in the query.

"SELECT `tasksentid` FROM `mytasksend` where `to` = '$username'"

I'm no android expert, but looking at your PHP, shouldn't you have quotes around $username? You should also really validate/clean any data coming via $_POST