1
I’m making a web page that contains login for an administrative area, but where I’m creating and testing (on a local server) is working normally. When I copy the project and put it on my laptop to test and present the project, the same code shows error.
Where I am creating the page and testing is Linux, in my notebook is Windows.
The Mysql routine is this:
if (isset($_POST["f_logar"])) {
$user=$_POST["f_user"];
$senha=$_POST["f_senha"];
$sql="SELECT * FROM tb_colaboradores WHERE username='$user' AND senha='$senha'";
$res=mysqli_query($con,$sql);
$ret=mysqli_fetch_array($res);
//MySQL
//pesq.user, se existir
//obter user e senha
//comparar. senha
if($ret == 0){
echo "<p id='lgErro'>Login inválido</p>";
}else{
$chave1="abcdfghijklmnopqrstuvwyz";
$chave2="ABCDFGHIJKLMNOPQRSTUVWYZ";
$chave3="0123456789";
$chave=str_shuffle($chave1.$chave2.$chave3);
$tam=strlen($chave);
$num="";
$qtde=rand(20,50);
for ($i=0;$i<$qtde;$i++) {
$pos=rand(0,$tam);
$num.=substr($chave,$pos,1);
}
session_start();
$_SESSION['numlogin']=$num;
$_SESSION['username']=$user;
$_SESSION['acesso']=$ret['acesso']; //0=restrito / 1=total
header("Location:gerenciamento.php?num=$num");
}
}
mysqli_close($con);
The error that presents in the notebook is this:
Warnig: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given in C: wamp www site login.php on line 28
Before line 28, right after
mysqli_query
, placedie(mysqli_error($con))
and see if any error message appears on the screen.– Woss
Appears Champ 'username' inconnu dans Where clause
– Wesley Alves
The column
username
exists in the tabletb_colaboradores
?– Woss
ssanosaaa that vacilo was with user in the table and was calling username. thank you very much [solved]
– Wesley Alves