Problem in update mysql

0

I have a function that performs an update:

function alterarConta(){
     $dataemissao = $_POST['dataemissao'];
     $id = $_POST['id'];
     $select_fornecedores = $_POST['select_fornecedores'];
     $valor = $_POST['valor'];
     $datavencimento = $_POST["datavencimento"];
     $especie = $_POST['especie'];
     $observacao = $_POST['observacao'];
     $banco = abrirBanco();
     $sql = " UPDATE contas SET c.dataemissao = '$dataemissao', c.id_fornecedor = '$select_fornecedores', c.valor = '$valor', c.datavencimento = '$datavencimento', c.especie = '$especie', c.observacao = '$observacao' FROM contas c INNER JOIN pessoa f ON (c.id_fornecedor = f.id) WHERE c.id = '$id'";
    $banco->query($sql);
    $banco->close();

    header('Location: consulta_contas.php');
}

I'm having trouble, I can not find where it's wrong.

The structure:

    
asked by anonymous 29.01.2018 / 17:05

1 answer

0

Well at the beginning of the update replace update contas with update c

After from you have set alises for the tables and when you try to perform the update directly in the table the update is lost and tries to update the table as a whole.

function alterarConta(){
     $dataemissao = $_POST['dataemissao'];
     $id = $_POST['id'];
     $select_fornecedores = $_POST['select_fornecedores'];
     $valor = $_POST['valor'];
     $datavencimento = $_POST["datavencimento"];
     $especie = $_POST['especie'];
     $observacao = $_POST['observacao'];
     $banco = abrirBanco();
     $sql = " UPDATE c SET c.dataemissao = '$dataemissao', c.id_fornecedor = '$select_fornecedores', c.valor = '$valor', c.datavencimento = '$datavencimento', c.especie = '$especie', c.observacao = '$observacao' FROM contas c INNER JOIN pessoa f ON (c.id_fornecedor = f.id) WHERE c.id = '$id'";
    $banco->query($sql);
    $banco->close();

    header('Location: consulta_contas.php');
}
    
29.01.2018 / 18:07