-1

I was trying to make a simple database to write and read from and on pretty much one of the first steps I encountered a problem: it would not connect. I got the error message: "No connection could be made because the target machine actively refused it.". I looked at other stack overflow questions and they all had complex solutions involving changing the code of some things. I tried some, and nothing changed. I am using USBWebServer and phpMyAdmin. This is the index.php code that failed:

    $servername = "127.0.0.1";
    $username = "root";
    $password = "usbw";
    $databasetouse = "work times web database";
    // Create connection
    $mysqli = new mysqli($servername, $username, $password, $databasetouse);
    
    // Check connection
    if ($mysqli->connect_error) {
      die("Connection failed: " . $mysqli->connect_error);
    }
    echo "Connected successfully";

I tried changing $servername to "localhost" and nothing changed. When I first tried to log in to phpmyadmin it showed that my password was usbw and my username was root.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Anders C
  • 3
  • 3

2 Answers2

-2

I faced this error when I was learning laravel. Actually this happens when you database server is not being started.

-2

Maybe you should start your Apache and MySQL server through Xampp control panel and then try to connect.

User_mad
  • 16
  • 1