Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
<?php
$servername = "localhost";
$username = "";
$password = "";
$conn = new mysqli($servername,$username,$password);
if($conn->connect_error) {
die("failed to connect to server".$conn->connect_error);
}else{
echo "connected successfully";
}
?>
Please sign in to leave a comment.
Please please send me some solution.
Hi there,
1) Please show a screenshot of what PhpStorm shows you there
2) PhpStorm version?
3) PHP version?
4) What class again? In subject you have one, in your code -- another one.
PHP version 7
PHPSTORM 2017.2.4
That error (No connection could be made because the target machine actively refused it.) has nothing to do with PhpStorm.
It must be either your MySQL server (e.g. server does not listen on that protocol (e.g. TCP - only sockets allowed); not enough access rights for that user (e.g. not allowed to connect from that IP/host)) or you have bad login details (login/password or even a server name/IP). Double check all that.
You may use StackOverflow or other similar sites for your PHP code issues.