title: Problems with Android and MySQL/PHP database connection
body: <p>I'm making a very simple Android app, but when I try to connect it to a web page it doesn't work. I have already tried a lot of tutorials on internet and I have already read a lot of topics here too, but without any success.
  So now I will explain you my code, hoping we can find a solution together. Thank you for now.</p>
  
  <p>This is the main java page, where I make the connection on the OnClick method:</p>
  
  <pre><code>package com.example.enchan.crazyup;
  
  import android.database.Cursor;
  import android.os.PersistableBundle;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.MenuItem;
  import android.widget.Button;
  import android.view.View;
  import android.content.Intent;
  import android.widget.EditText;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.io.BufferedInputStream;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.UnsupportedEncodingException;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLConnection;
  import java.net.URLEncoder;
  import java.util.List;
  
  import android.util.Log;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  
  import java.net.URL;
  
  import android.view.Menu;
  import android.app.Activity;
  import android.widget.Toast;
  
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  public class FollowUsActivity extends AppCompatActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_follow_us);
  
          findViewById(R.id.subscribe).setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  EditText email = (EditText) findViewById(R.id.email);
                  String pkg = getPackageName();
  
  
                  URL url_page = null;
  
                  try {
                      url_page = new URL("http://crazyup.altervista.org/select_email.php?email==" + email.getText().toString());
                  } catch (MalformedURLException e) {
                      e.printStackTrace();
                  }
  
                  try {
                      HttpURLConnection client = (HttpURLConnection) url_page.openConnection();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }                Intent OpenNewEmailActivity = new Intent(FollowUsActivity.this, NewEmailActivity.class);
                  Intent intent = OpenNewEmailActivity.putExtra(pkg + "Test", email.getText().toString());
                  startActivity(OpenNewEmailActivity);
              }
          });
      }
  }
  </code></pre>
  
  <p>And this is the corrispondent .xml main file:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:background="@drawable/bg_follow_us"
      tools:context="com.example.enchan.crazyup.FollowUsActivity"&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/subscribe"
          android:src="@drawable/iscriviti"
          android:layout_marginBottom="41dp"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;EditText
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:inputType="textEmailAddress"
          android:ems="10"
          android:id="@+id/email"
          android:layout_above="@+id/subscribe"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Indirizzo Email"
          android:id="@+id/email_title"
          android:layout_above="@+id/email"
          android:layout_centerHorizontal="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In the Manifest there are these permissions:</p>
  
  <pre><code>    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>The php page is this (and it works if I open it on browser):</p>
  
  <pre><code>    &lt;?php
  
  mysql_connect("localhost","crazyup","");
  mysql_select_db("my_crazyup");
  
  $s_email = $_GET['email'];
  $string = "INSERT INTO email (content) VALUES ('".$s_email."')";
  $q = mysql_query($string);
  
  if (!$q) {
      die("Errore nella query: " . mysql_error());
  }
  
  /* $q = mysql_query("SELECT * FROM email WHERE email =".$s_email);
  while($e = mysql_fetch_assoc($q))
          $output[] = $e;
  print(json_encode($output)); */
  
  mysql_close();
  
  ?&gt;
  </code></pre>
  
  <p>I have read that a probably problem could be the Android version (Marshmallow or Lollipop) but I've tried both and I have the same thing.
  In the logcat there are NO errors, so I can't understand why the app not works.</p>