2019-04-06 07:53
浏览 147


I've created a database using Microsoft Azure Portal (MySQL Database).

Currently I'm using PHP to connect to the database.

$servername = "";
$username = "username@server";
$password = "password";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname, 3306);
// Check connection

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

SQL queries to populate data in JSON format.

$sql = "SELECT id, username, score FROM ScoreTable";
$result = $conn->query($sql);

$dbdata = array();
 while ( $row = $result->fetch_assoc())  {

echo json_encode($dbdata);

Result (localhost/jubakee.php OR (local IP) both produce the same results).


The issue I am having is that I want to be able to access this database from different networks e.g on 3G/4G or my friend's house.

When trying to load on my android device it will only produce the results if I'm on the same network as my PC (Same Wi-Fi Network).

When I switch my network from Wi-Fi to Mobile Data (3G) I can no longer access the database and will not load.

The purpose of this is so I can create an online database which will interact with my C# android application. The database will store the scores of the users.

How can I allow users using different networks to connect to my database?

Thank you.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doudou8783 2019-04-06 12:26

    You can't not access the xamp server from your cellular data or different wifi networks. You have to upload your database and files in a live server like 000webhost then you will have a url like Now you can access this url from anywhere, anytime and in any applications.

    解决 无用
    打赏 举报

相关推荐 更多相似问题