I am able to connect to the mysql server from the terminal on my local system but cannot connect to it from my php code.
<!-- Establish conenction to sql -->
<?php
session_start();
$servername = "ec2-xxxx.compute-1.amazonaws.com";
$username = "username";
$password = "password";
$dbname = "database_name";
// Create connection, the code hangs on this line
$conn = new mysqli($servername, $username, $password, $dbname);
?>
The code seems to hang on the 'new sqli' line. I tried placing it inside a try-catch block, but the catch block is never executed. Nothing gets executed beyond that line.
Edit: Dipti suggest that I place ini_set('display_errors', 1); on top on the php file. This gave me an output saying that mysqli couldn't be found. Doing a "sudo apt install php-mysql" fixed the issue.