1
I have a problem in the code that my teacher passed, I would like to change to mysqli
, but I couldn’t get the mysql_result
. Here’s the code he gave me, if anyone can help me, I’d appreciate it.
<?php
//CONECTA COM O BANCO DE DADOS
require_once("conecta.php");
$usuario = $_POST['nome'];
$senha = $_POST['senha'];
$sql = mysql_query("SELECT A.apelido_cliente, A.nome_cliente, A.email_cliente FROM tbl_cliente A WHERE A.apelido_cliente = '$usuario' AND A.senha = '$senha'") or die("ERRO NO COMANDO SQL");
//LINHAS AFETADAS PELA CONSULTA
$row = mysql_num_rows($sql);
//VERIFICA SE RETORNOU ALGO
if($row == 0){
echo "Usuário/Senha inválidos";
echo "<br><a href='login.php'>Voltar</a>";
} else {
//PEGA OS DADOS
$id = mysql_result($sql, 0, "cod_cliente");
$nome = mysql_result($sql, 0, "nome_cliente");
$email = mysql_result($sql, 0, "email_cliente");
//INICIALIZA A SESS�O
session_start();
//GRAVA AS VARI�VEIS NA SESS�O
$_SESSION["id"] = $id;
$_SESSION["nome"] = $nome;
$_SESSION["email"] = $email;
//REDIRECIONA PARA A P�GINA QUE VAI EXIBIR OS PRODUTOS
Header("Location: menu.php");
}
?>
What kind of problem are you having with msqli? jan tried to look at the manual? http://php.net/manual/en/book.mysqli.php
– Sullyvan Nunes
Switching from mysql to mysqli
– rray
rray as stated in the content, my difficulty is in the
mysql_result
which would have the function of storing the received data for a variable, I have searched in several foruns to see if it has something equivalent in themysqli
, but I found nothing. In the possible "duplicate" he wants to know how to change all the code, in mine I want to know how to changemysql_result
, I just put the codemysql
, the way they showed me– Guilherme Menecucci