不从免费主机获取数据,但在localhost中正常工作

时间:2017-12-17 15:22:24

标签: php android localhost android-volley web-hosting

我有一个Android应用程序,用volley和php从服务器获取一些数据。我的应用程序在localhost中正确获取但是当把php文件放在像infinityfree.net这样的免费网络主机中取不行时:(。甚至在我的浏览器中测试网址并正确获取!但在我的应用程序中不能正常工作。我的清单中的我的网络首选项是对的。任何人都有想法吗?

我的php

<?php 

include 'dbconfig.php';

 $con = mysqli_connect($servername,$username,$password,$dbname);
  //creating a query
  $stmt = $con->prepare("SELECT

POWER,
POWER1,
POWER2
FROM turbine_table ORDER BY id DESC LIMIT 1;");

//executing the query 
$stmt->execute();

//binding results to the query 
 $stmt->bind_result(

$t1,
$t2,
$t3
 );

 $boiler = array(); 

 //traversing through all the result 
 while($stmt->fetch()){
 $temp = array();

 $temp['t1'] = $t1;
 $temp['t2'] = $t2;
 $temp['t3'] = $t3;


 array_push($boiler, $temp);
 }

 //displaying the result in json format 
 echo json_encode($boiler);
 ?>

0 个答案:

没有答案