I have a .php file from which I connect to a remote database of a server that I have. It never makes the connection, and I think it's the fault of the code. Since remote configuration is enabled, the sql user is configured to connect from any IP .
The DB is MariaDB
From the mysql workbench I can connect without any problem, from php code it gives me an error
PHP version: 7.3.11
DB Version: 10.3.17-MariaDB
Code
$user = "remote";
$password = "1234";
$server = "192.168.1.17";
$bbdd = "login";
$table_users = "login";
$connect = mysqli_connect($server, $user, $password);
$db = mysqli_select_db($connect, $bbdd);
if (isset($_POST['username']) && isset($_POST['password']) ){
$query = "SELECT * from " + $table_users + " WHERE user = '" + $_POST['username'] + "'";
$result = mysqli_query($connect , $query);
// No esta en un while porque solo devolvera una linea de la bbdd, ya que el username es unico
$info = mysqli_fetch_array($result);
if ($info['user'] !== $_POST['username'] && $info['passw'] !== $_POST['password']) {
echo 0;
}else {
echo 1;
}
}else{
echo 0;
}
Your error is at the time of declaring the variable
$query
In
PHP
the concatenation it is done with a dot.
, change it to this: