If the PHP code doesn't return any error, there can be multiple reasons why the PHP code can connect to the database. Please ensure that you can access the database from the machine where the PHP code is before running the code. Once you confirm that, I suggest you ask in a specialized PHP forum in order to debug your code.
This Community forum is intended to solve problems related to the Bitnami Stacks, Virtual Machine or Cloud Images. For information regarding the application itself or customization of the content within the application, we highly recommend checking forums and user guides made available by the project behind the application.