I was trying to use a PHP connection to connect MySQL Database which was on PHPMyAdmin. Nothing fancy about the connection just trying to see whether the connection was successful or not. I was using MAMP to host the database, the connection I was trying to use is this:
$username = "root";
$password = "root";
$conn = new PDO("mysql:host=$servername;dbname=AppDatabase", $username, $password);
echo "Connected successfully";
echo "Connection failed: " . $e->getMessage();
I had been using postman to test to see if the connection was working, but I kept receiving this error message:
Connection failed: SQLSTATE[HY000]  Connection refused
Before I was receiving an error message of:
Connection failed: SQLSTATE[HY000]  No such file or directory
This was because I had set the servername to localhost, through changing this to the IP address it had given me the connection refused and I have no idea what is wrong.
Any help regarding this would be appreciated.