I can not connect to the database

hola chicos, tengo un problema no puedo acceder a mi web , mi script php de conexion es el siguiente :
<?php

$host="localhost";
$user="idxxxxxxx_root";
$pass="xxxxxxxxx";
$db="idxxxxxxx_inventaio";



$connect = new mysqli($host,$user,$pass,$db) or die("error" . mysqli_errno($connect));

?>

change the version from 7.1 to 5.6 and it is the same result, I know it does not connect because I have a login and when I modify the index and enter without the php code of the login, it does not consult the database :frowning:

hey please try this way :
$mysqli = new mysqli($host, $user, $pass, $db);
/* check connection */
if (mysqli_connect_errno()) {
printf(“Connect failed: %s\n”, mysqli_connect_error());
exit();
}

I used that code but it did not work :frowning:

Instead of

$connect = new mysqli($host,$user,$pass,$db) or die("error" . mysqli_errno($connect));

Use

$connect = new mysqli($host,$user,$pass,$db) or die("error" . mysqli_connect_error($connect));

not work, I have seen in some comments that do not point to “localhost” but to mysql xx.000webhost.com "but how to know what is my mysql webhost server? really not because it does not connect to the database

Localhost is the only one you can use with our free hosting.

Are You Sure It Is Not An Error In Your PHP script?

ready problem solved, changing the connection in my php scripts of the login and registries, thank you very much for your answers :smiley:

1 Like