I have this code:
<?php
class Conexion {
private $host = "localhost";
private $user = "root";
private $pass = "";
private $bd = "nutricion";
private $con;
public function Conectar() {
$this->con = mysqli_connect($this->host, $this->user) or die("Error al conectar al Servidor");
mysql_select_db($this->bd, $this->con) or die("Ha ocurrido un Error al conectar a la Base de Datos");
}
}
?>
Which generates the following error:
Warning: mysqli_connect (): (HY000 / 2002): No connection could be made because of the target machine. in C: \ xampp \ htdocs \ admin \ classes \ Connection.php on line 10 Error connecting to the Server
I have tried new ways to connect the database with other codes but all of them generate an error, two years ago this code worked perfectly for me, I'm going back to the project and I'm not good at php, I hope someone can help me.