Changing mysql_result to mysqli

Asked

Viewed 42 times

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

  • 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 the mysqli, 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 change mysql_result, I just put the code mysql, the way they showed me

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.