I am using one database for android application and website. So admin can update website and android application through one admin panel and at once time. For android application, database is connected through API. The problem is that android application run smoothly only if I drop table that are not associated with application. Database contains 15 table. Among them 3 tables are jointly used for android application and website. If I drop rest of tables except these 3 tables, android application run smoothly. But If I don't drop other tables, android application hardly fetch data. At same time, if I run website (while application loading) website can't load.
This site can’t be reached
........took too long to respond.
ERR_CONNECTION_TIMED_OUT
I think problem in following code.
api.php
$con = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8;","$dbuser","$dbpass");
if(isset($_GET['cat_id'])){
$result=$con->prepare("SELECT * FROM tbl_news_category c,tbl_news n WHERE c.cid=n.cat_id and c.cid='".$_GET['cat_id']."' ORDER BY n.nid DESC");
}
else if(isset($_GET['latest_news'])){
$limit=$_GET['latest_news'];
$result=$con->prepare("SELECT * FROM tbl_news_category c,tbl_news n WHERE c.cid=n.cat_id ORDER BY n.nid DESC LIMIT $limit");
}
else if(isset($_GET['apps_details'])){
$result=$con->prepare("SELECT * FROM tbl_settings WHERE id='1'");
}
else{
$result=$con->prepare("SELECT * FROM tbl_news_category ORDER BY cid DESC");
}
$set = array();
$result->execute();
$total_records = $result->rowCount();
if($total_records >= 1){
while($link=$result->fetch(PDO::FETCH_ASSOC)){
$set['NewsApp'][] = $link;
}
}
echo $val= str_replace('\\/', '/', json_encode($set));
?>
After forcefully terminate android application, website run smoothly. First fall I think it is cache/poor connectivity problem. I changed internet connectivity, cleared cache, used other device, PC, browser. But problem can't solve. If I use two database, it works fine. I don't want to store same content in two database. Actually what caused the problem, hosting server or code ??