用于MYSQL的PHP​​脚本在一个文件上工作,而不是在另一个文件上

I currently have an AngularJS application querying a database through a factory linked to a PHP script. The script below works exactly as planned and outputs the JSON used for Angular:

<?php
function getCompanyDetails($company_id)
    {
        // Connect to the database.
        require_once("config/connection.php");

        $query = "SELECT id, header, content FROM company_details WHERE company_id = ?;";

        $stmt = $conn->stmt_init();

        if($stmt->prepare($query)) {
            $stmt->bind_param("i", $company_id);
            $stmt->execute();

            $data = $stmt->get_result();

            while($row = $data->fetch_assoc()) {
                $result[] = $row;
            }

            header("Access-Control-Allow-Origin: *");
            header("Content-Type: application/json; charset=UTF-8");

            $stmt->close();
            mysqli_close($conn);
            echo json_encode($result);
        }
    }

getCompanyDetails(1);

?>

Now, I have other sections of the application which require the exact same action (Selecting results from the database) and I am using the following script (an almost identical copy to the one above):

<?php
function getCompanyProjects($company_id)
    {
        // Connect to the database.
        require_once("config/connection.php");

        $query = "SELECT title, description FROM company_projects WHERE company_id = ?;";

        $stmt = $conn->stmt_init();

        if($stmt->prepare($query)) {
            $stmt->bind_param("i", $company_id);
            $stmt->execute();
            $data = $stmt->get_result();

            while($row = $data->fetch_assoc()) {
                $result[] = $row;
            }

            header("Access-Control-Allow-Origin: *");
            header("Content-Type: application/json; charset=UTF-8");

            $stmt->close();
            mysqli_close($conn);
            echo json_encode($result);
        }
    }

getCompanyProjects(1);

?>

The problem is, the second script will not return any results. There are records in the database for the table and I believe I am closing the connection after each use. I have been stuck on this for a while now, does anybody have any idea of what the problem could be?

The query SELECT title, description FROM company_projects WHERE company_id = ?; works on phpMyAdmin.

Thanks in advance.

After trying fetch_assoc(), fetch_array(), mysqli_fetch_assoc() and many others, resetting the server a few times, placing echos and var_dumps everywhere, I realized all the data was being retrieved up until the while section.

When I actually iterated var_dump inside the while loop, I saw a little symbol for unrecognized character. There was an unescaped quote in one of the last results. After removing this little friend, fetch_assoc() started working well again. The problem was in the actual data, not on the code. Both scripts are working properly now with the correct data.

Thanks for all the help, everyone! I had no idea what var_dump was before asking this question, a really useful function.