Problems with PHP connecting to Mysql

phpstudy configuration apache and mysql display enable the service, and the command line connection can also be connected, but the following statement shows that the connection cannot be made in php:
$con = mysqli_connect ("localhost", "root", "root");
if ($con)
{
die ("Could not connect.". Mysqli_errno ($con));
}
) always shows what other possible locations are errors under Could not connect, advice?

Php
Mar.21,2021

if(!$con)
{
    ...
}
if,false,

replace mysqli_errno ($con) with mysqli_connect_error () , output error details


this is too many possible cases
1. Your account password is incorrect
2. Maybe the default port of your mysql is not 3306
, so you can follow your brother upstairs to use mysqli_connect_error () to get the details of the link error.


shows that this Could not connect shows that $con is a resource returned by true,. Of course, it is true, your logic, convinced

.
Menu