my code on php:
<?php
$username ='root';
$password ='abc';
$hostname ='localhost';
$database ='test_xmpp';
$localhost = mysql_connect($hostname,$username,$password) or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database,$localhost);
$groupmates = array();
$abc=mysql_query('SELECT count(1) FROM groupchat');
$groupcount= mysql_result($abc,0);
$groupcount = $groupcount + 1;
echo $groupcount;
$admin = $_POST["admin"];
$groupname = $_POST["groupname"];
$groupmates = $_POST["groupmates"];
$sql="INSERT INTO groupchat (idgroupchat,groupname) VALUES ('$groupcount','$groupname')";
mysql_query($sql);
$b = '2';
$a = $groupmates[0];
$sql1="INSERT INTO groupuser (idgroup, username, admin) VALUES ('$groupcount','$a','$b')";
mysql_query($sql1);
?>
my code on android:
public static class TestAsyncTask extends AsyncTask<String, Integer, String> {
protected String doInBackground(String... urls) {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("admin", admin));
nameValuePairs.add(new BasicNameValuePair("groupname", groupname));
for (int i=0;i<8;i++)
{
nameValuePairs.add(new BasicNameValuePair("groupmates",groupmates[i]));
}
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.102/webservice/issertgroup.php");
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
question: $groupmates[0] is null. how can i get the array passing from the android??
i fail with using this method. please help me to solve this. i have searched a lot of references in google, but still cannot solve my problem.