How to get a user's code via SESSION

0

Hello. I wanted to know if this is possible.

$nome=$_SESSION['nome'];
$codigoUsuario=buscaUsuario($nome);
inserirVenda($codigoUsuario,$codigoProduto);

I get his name via session step to a variable, I search the bank and return his code to insert it into another table in the bank. The following error is occurring.

Object of class mysqli_result could not be converted to string

Here is where I get the information that was sent from the html.

   $nome=$_SESSION['nome'];
            $resultado2=buscaUsuario($nome);
            if($resultado2){
                while($linha = mysqli_fetch_assoc($resultado2)){
                    $codigoUsuario=$linha['codigoUsu'];
                }
            }

            inserirVenda($codigoUsuario,$codigoProduto);

You're giving an error in the insertVend function.

function inserirVenda($codigoUsuario,$codigoProduto){
    conectar();
    query("INSERT INTO venda (codigoProduto,codigoUsuario) VALUES ($codigoProduto,$codigoUsuario)");
    fechar();

}

Fatal error: Uncaught Error: Call to undefined function mysql_connect_error () in C: \ xampp \ htdocs \ igor_trabalho2 \ connectionBD.php: 22 Stack trace: # 0 C: \ xampp \ htdocs \ igor_trabalho2 \ crudVenda. php (36): query ('INSERT INTO ven ...') # 1 C: \ xampp \ htdocs \ igor_trabalho2 \ controlVenda.php (26): insertVend ('12 ',' code ') # 2 {main} thrown in C: \ xampp \ htdocs \ igor_trabalho2 \ connectionBD.php on line 22

    
asked by anonymous 12.11.2018 / 03:32

0 answers