MySQL connecting error

Hi I am making a Login/Register system, and I can’t connect to InfinityFree MySql. I’ve tryed to host locally a mysql db and it worked, but when I try to connect to infinityFree Sql I cant

The error is in spanish (sorry):

Warning: mysqli::__construct(): (HY000/2002): Se produjo un error durante el intento de conexi?n ya que la parte conectada no respondi? adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexi?n establecida ya que el host conectado no ha podido responder. in E:\xammp 7.2.7\htdocs\Dragonlandia\register\index.php on line 4

That’s the code

`<?php
session_start();
$SESSION[‘message’] = 'Crea tu cuenta ^^';
$mysqli = new mysqli(‘sql108.epizy.com’,‘epiz_22500190’,‘aPasswordThatIMustn’tShare’,‘members’);

if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {

if($_POST[‘password’] === $_POST[‘confirmpassword’]){

$username = $mysqli->real_escape_string($_POST['username']);
$email = $mysqli->real_escape_string($_POST['email']);
$password = md5($_POST['password']);

$_SESSION['username'] = $username;

$sql = "INSERT INTO epiz_22500190_members (username,email,password)" . "VALUES ('$username','$email','$password')";

if($mysqli->query($sql) === true) {
  $_SESSION['message'] = "Registrado satisfactoriamente!";
  header("location: ../");
}
else {
  $_SESSION['message'] = "El usuario no ha sido aadido a la DB. Contacte al soporte si le pasa mas veces [email protected]";
}

}
else {
$_SESSION[‘message’] = “La constraseas no coinciden!”;
}
}

?>`

mysqli('sql108.epizy.com','epiz_22500190','aPasswordThatIMustn'tShare','members');

notice apostrophe here ThatIMustn’tShare

this will break the code - remove it

https://infinityfree.net/support/common-mysql-errors/

also if you think from your local pc connect to infinityfree then you can not
https://infinityfree.net/support/connecting-to-mysql-from-elsewhere/

@OxyDac said:
mysqli('sql108.epizy.com','epiz_22500190','aPasswordThatIMustn'tShare','members');

notice apostrophe here ThatIMustn’tShare

this will break the code - remove it

https://infinityfree.net/support/common-mysql-errors/

also if you think from your local pc connect to infinityfree then you can not
https://infinityfree.net/support/connecting-to-mysql-from-elsewhere/

OxyDac thanks for trying to help, but did you know I have replaced the real pass by this because is a password that i mustn’t share ^^

And the second thing, I only can connect to MY localhost, the problem is I can’t connect to infinityfree sql anyway

I checked your code and this fragment caught my attention:

in E:\\xammp 7.2.7\\htdocs\\Dragonlandia\\register\\index.php on line 4

Please note that you can only connect to the databases on your hosting account from within that account. Connecting to the databases from elsewhere (whether that’s PHP code on your computer, a mobile app or something else) is not possible. Remote MySQL Access is a premium only feature.

(also, you can use triple backticks if you need to format multiple lines of code: Markdown Cheatsheet · adam-p/markdown-here Wiki · GitHub )

Hello Admin, there is some problem, when I try to testRegister in my page, it “connect” to database but now gives me only my personalized error (“There was a problem registering to DB, if you have more problems like this contact to emailofmysite” and at the end of the email i said to give the error in text but doesn’t gives it). So now I will start testing and checking if I can do this properly. If it stills with the problem I will send information ^^.

(sorry for my english)

PD: Is there any chat like DM to have instant response?

Oh, now it works, thanks Admin. And sorry for wasting your time in me ^^