3
I have a question in a code in PHP.
My code is generating several alerts:
And it seems to me that the same is not making connection with the database, because I am sending him to print some data and it does not print anything on the screen.
I’m going to put some code here:
<?php
$conectar = mysqli_connect("localhost","root","") or die ("Erro na conexão");
mysqli_select_db("painel_admin");
?>
<?php
session_start();
$usuariot = $_POST['usuario'];
$senhat = $_POST['senha'];
include "conexao.php";
$result = mysqli_query("SELECT * FROM usuario WHERE usuario='$usuariot' AND senha='$senhat' LIMIT 1");
$resultado = mysqli_fetch_assoc($result);
if(empty($resultado)){
$_SESSION['loginErro'] = "Usuário ou senha inválido";
header ("Location: login.php");
}
?>
Man, every Warning has a message. Just read the messages and see what each one says.
– Jéf Bueno
Pass the connection as the fourth argument of
mysqli_connect()
then don’t forget to pass the connection as the first argument inmysqli_query()
– rray
Would that be:<? php $connect = mysqli_connect("localhost","root","","painel_admin") or die ("Connection error"); mysqli_select_db("painel_admin"); ?>
– Pedro Ribeiro
Passes the name of the bank directly on
mysqli_connect
:$conectar = mysqli_connect("localhost","root", "", "painel_admin");
– usuario
It was right to go straight to mysaqli_connect, THANK YOU!!
– Pedro Ribeiro