Hello colleagues, please, if you can help me, give me the following error.
Warning: mysqli::__construct(): (HY000/2002): Solo se permite un uso de cada
direcci�n de socket (protocolo/direcci�n de red/puerto) in C:\wamp64\www\OnlineVentas\com.modelo.conexion\conexion.php on line 12
my connection is like this
<?php /* dbconnect.inc.php */
function Conectarse()
{
$mysqli = new mysqli('localhost', 'root', '1234', 'tienda');
$mysqli->set_charset("utf8");
return $mysqli;
}
$link=Conectarse();
?>
Reading an earlier article, I did it like that
<?php /* dbconnect.inc.php */
define("DB_HOST", "localhost");
define("DB_USERNAME", "root");
define("DB_PASSWORD", "1234");
define("DB_NAME", "tienda");
define("DB_ENCODE", "utf8");
function Conectarse()
{
// $mysqli = new mysqli('localhost', 'root', '1234', 'tienda');
$conexion=new mysqli (DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
mysqli_query($conexion, "SET NAMES'".DB_ENCODE."'");
if(mysqli_connect_errno()){
printf("fallo mijin:", mysqli_connect_errno());
exit();
}
return $conexion;
}
$link=Conectarse();
?>
Still the error follows if you can help me please