Help me sir for this error, Connect Error (2002) No connection could be made because the target machine actively refused it.

my connection
//my database class

class Db {
    // make sure we dont connnect database to every function
    public $mysql;
    function __construct(){
        $this->mysql = new mysqli('','sa','P@ssw0rd','PLAZATOYOTA_MSCRM');
        if (mysqli_connect_error()) {
            die('Connect Error (' . mysqli_connect_errno() . ') '
                    . mysqli_connect_error());
$db = new DB();

my code :

  $db = new Db();
                  $query = "SELECT * from account";
                  $results = $db->mysql->query($query);
                      while($row = $results->fetch_object()) {
                          // $title = $row->title;
                          // $description = $row->description;
                          // $id = $row->id;


                          //the rest of the code go here...

 i want make json but i can't , because that error in my xampp.


Generally that error is not due to your code. Either the firewall is blocking you or the database is listening on a specific port.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.