I am having trouble sending a GCM registration_id to my database from Android. I have a script on my server that if I type "....name.php?regid=APA91bHmcD3_yZijf7dmmWlPiyi39Zx2kRTVHdI" it will work. However, when I try to send it through Android it won't.
Here is my code:
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.domain.com/newnotifier.php");
Log.d("TAG", regid);
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("regid", regid));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
Just need to know why this won't work. I look in my logcat and it shows the entire id being sent over.
Thanks,
EDIT: It doesn't give a error, it just doesn't show anything in the database. EDIT 2: PHP Code
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if ($con)
{
}
mysql_select_db($mysql_database, $con);
name1 = $_REQUEST['regid'];
$sqldo = mysql_query("INSERT into users(regid) VALUES('".$name1."')");