0

Good evening to all,

I would insert a string on db that hosted in my web page.

I've created a php file that with a GET method pass the param that I would insert.

This method on the browser work but if i call it on Android app with the following code not work. Why? Can you help me?

inviaButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view){
                String prova = "ciao";

                try {

                    URL paginaURL = new URL("http://www.differenziapp3.altervista.org/insertSegnalazione.php?descr=" + prova);
                    HttpURLConnection con = (HttpURLConnection) paginaURL.openConnection();
                } catch (Exception e) {}
            }
        });

This is php file :

<?php
include("connessione.php");

$descr=$_GET['descr'];
$idp="vuoto";
$idp2=0;

$query="INSERT INTO segnalazione(foto,data,ora,lati,longi,descrizione)VALUES
('".$idp."','".$idp."','".$idp."','".$idp2."','".$idp2."','".$descr."')";
mysql_query($query);

?>

Thanks for all

Alberto
  • 13
  • 7
  • Not insert the string on db – Alberto Feb 26 '16 at 17:08
  • What does your app do? Does it connect or does it crash? Have you set the correct permissions in the `manifest` file? Are you running this off the `UI` thread? – Pztar Feb 26 '16 at 17:17
  • I think we need to see your php code to know why it's not inserting. Have you tried running the URL in a browser to see what happens? – Kristy Welsh Feb 26 '16 at 17:19
  • The internet permission are setting on Manifest and the php on browers works and insert, the param that pass in url, in db – Alberto Feb 26 '16 at 17:27

0 Answers0