0
Hi. I was wondering if that’s possible
$nome=$_SESSION['nome'];
$codigoUsuario=buscaUsuario($nome);
inserirVenda($codigoUsuario,$codigoProduto);
I take his name via session step to a variable, I search the bank and return your code to insert it in another table in the bank. The following error is happening.
Object of class mysqli_result could not be converted to string
here is where I get the information that was sent from html.
$nome=$_SESSION['nome'];
$resultado2=buscaUsuario($nome);
if($resultado2){
while($linha = mysqli_fetch_assoc($resultado2)){
$codigoUsuario=$linha['codigoUsu'];
}
}
inserirVenda($codigoUsuario,$codigoProduto);
Giving an error in the function insert.
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_work 2 connectionBD.php:22 Stack trace: #0 C: xampp htdocs igor_work 2 crudVenda.php(36): query('INSERT INTO ven...') #1 C: xampp htdocs igor_work 2 controleVenda.php(26): inserirVenda('12', 'code') #2 {main} thrown in C: xampp htdocs igor_work 2 connectionBD.php on line 22
This error indicates that the way you are treating the output is wrong. The mysqli_result returns an object, not a string, so you can’t just have the variable printed, it has to pass through a repetition loop first to then access the specific object indexes. Post more of your code!
– Igor Serafim
it really was. But now this giving a bank error
– igorvp