I am hosting a local database that I am having trouble connecting to. I have everything set up through MAMP. I know that my db user, pass, name, and host variables are correct, and I went into my Windows firewall to open up the TCP ports ingoing and outgoing. However, I am still getting the following message when I run the code below:
Connect failed: 2003
Does anyone know what this error number means? Below is the php code I am trying to run.
<?php
$db_user = 'db';
$db_pass = 'dbpass';
$db_name = 'dbname';
$db_host = 'localhost';
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
if ($mysqli->connect_errno)
{
printf("Connect failed: %s\n", $mysqli->connect_errno);
exit();
}
Try this
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);