Are there any reasons why this might be the case?
Here’s the code:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
echo $dbc;
if(!$dbc){
die('could not open a connection'.mysqli_connect_errno() . mysqli_connect_error());
}
Again, if I replace mysqli with mysql I get a returned dbc resource id (I assume that’s good). I would like to use mysqli as I hear it’s much better/faster. Right now I’m getting error code 2003.
mysql_connect()andmysqli_connect()use two different default ports from the php.ini file. I wouldn’t guess that these would be different than the standard default 3306, but worth a check or try adding the path to the host url.mysqli_connect:
mysql_connect:
Edit: I was wrong because I didn’t read the manual page far enough.
I think your connection is fine, but you wouldn’t want to check the object it returns as you have above. You’d want to use
mysqli_connect_errno(). Below is the example from PHP.net.Source