0

I'm trying to connect to my database locally with php however I'm getting the error that the target machine is refusing it and it's pointing to line 8 of my php code
Below I posted the code along with the error
// I'm sure that I defined the credentials correctly //

<?php
/* Database credentials.*/
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'ajay199ishere');
define('DB_NAME', 'oasis_water');

/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
  • For that go to this link [Click Me](https://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it) – PLB Nov 26 '18 at 06:50

3 Answers3

1

Make sure to check image for refernce that your xampp servers mysql service is started or not

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
aashish
  • 11
  • 1
0

Make sure that your mysql service is running on port 3306.

kishan
  • 138
  • 1
  • 3
  • 11
0

Check if MySql server is On and If is already serving on the right port

vivvaa
  • 1