I am trying to create a REST API to gather/send some data to a MySQL database I have running on a RHEL 7 Server. I have made a series if php files that I uploaded into my apache document root that for now simply connects to the DB and then lists all the entries from every table. When I run the PHP files from the server in command line, I get the appropriate JSON output echoed out to the terminal.
However, when I visit my server from a remote web browser, going to the PHP files results in a blank page every time. I have ensured that PHP is configured correctly is apache's httpd.conf file so I am very lost as to what my next steps should be.
Edit: Here is one of my PHP files:
<?php
$con=mysqli_connect("localhost","root","password","dbname");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT * FROM dbname.Table;";
if ($result = mysqli_query($con, $sql))
{
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_object())
{
$tempArray = $row;
array_push($resultArray, $tempArray);
}
echo json_encode($resultArray);
}
mysqli_close($con);
?>