I have created a simple php program running on apache2 server, php does work, but it is not connecting to the sql server when I view the file on another device. The database I am using on my Debian 9 device is MariaDB.
<?php
$conn = new mysqli("localhost","root","password","login");
$query = "SELECT * FROM users WHERE username = 'Martin';
$result = $conn->query($query);
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row['password'];
?>
I am prety sure I got the code right (i have tried mysql_connect and other methods). I dont understand why the webpage is giving me an error when I try and view the page on another device.
The times it worked varied when I was using the Debian device. It would sometimes work, and sometimes not. The tables and database in the sql server is fine, I have checked it over, and I dont think it is a fault with that.
MariaDB [(none)]> select * from login.users;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
| 1 | Martin | pass |
+----+----------+----------+
1 row in set (0.01 sec)
MariaDB [(none)]>
Can someone help me? I think that I have to enable something in apache files but my knowledge is limited and I dont know what kind of problem I am getting.