Before to get data from mysql database I need to make sure that the wamp server is online, if not, the app tell the user to put it online before pull data, how can this achieve in android? as if it is offline android app stopped!
PHP code to conect to database is:
<?php
//receive datatbase Info. from android app
$json=$_SERVER['HTTP_JSON'];
var_dump($data);
$data=json_decode($json);
$dbname=$data->dbname;
$dbpass=$data->dbpass;
$link=mysql_connect("localhost","root",$dbpass);
if (!$link) {
echo "error";
die(mysql_error());
}
$db_selected=mysql_select_db($dbname,$link);
if (!$db_selected) {
die ('error'. mysql_error());
}
mysql_query("set names 'utf8'");
mysql_query("set CHARACTER set 'utf8'",$link);
mb_internal_encoding("UTF-8");
?>
But in andorid app it does not receive "error" when there is no connection (I mean when wamp server is offline)?
In sum please, If there is any way to make sure that the wamp server is online before pull data start from database? and if not give user msg.
with tired mood I tried but with no result, really any help will be appreciated!