I have a value on a database and can finally display it in a textView, now i want to update that number on buttonclick.
The php-scripts work fine, if I open them in my browser and check my DB, the value changed +1.
Now my question is:: How can i execute this file from my android app? I don't want to read it, I just want to execute the file once, so that the value in the DB changes. I tried it this way:
public void updateData(String uri) {
try {
URL url = new URL(uri);
HttpURLConnection connn = (HttpURLConnection) url.openConnection();
connn.connect();
} catch (Exception e) {
e.printStackTrace();
}
}
This is my PHP-File but as mentioned before it works fine::
/*
$con = mysql_connect('127.0.0.1', 'root', '');
if(!$con)
{
die('could not connect to database' . mysql_error());
}
mysql_select_db('vehicles', $con);
$plusOne = ("UPDATE `counter` SET cars = cars + 1 WHERE id = 1;");
mysql_close($con);
?> */
EDIT:: Ok nevermind everything works fine now :)