Form error online

1

In the browser the following error has occurred, I have tried everything if you can help

  

Parse error: syntax error, unexpected $ end, expecting T_VARIABLE or   T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in

<?php
echo "NOVO MOTORISTA";
include('conexao.php');
if(isset($_POST['submitted'])){
    foreach($_POST AS $key=>$value){$_POST[$key] = mysql_real_escape_string($value);}
    $sql = "INSERT INTO 'motoristas'('cod_mot', 'nome', 'endereco', 'cidade','cod_veiculo')
    VALUES('{$_POST['cod_mot']}', '{$_POST['nome']}, '{$_POST['endereco']}, '{$_POST['cidade']}, '{$_POST['cod_veiculo']}')";
    mysql_query($sql) or die(mysql_error());
    echo "registro adicionado.<br/>";
    echo "<a href='listar_m.php'>Voltar à listagem</a>;
}
?>
<html>
<form action= method='POST'>
<p><b>Cod Mot:</b><br/><input type='text' name='cod_mot'/>
<p><b>Nome:</b><br/><input name='nome' type='text' size= '50'/>
<p><b>Endereco:</b><br/><input name='endereco' type='text' size='50'/>
<p><b>Cidade:</b><br/><input name='cidade' type='text' size='50'/>
<p><b>Cod Veiculo:</b><br/><input type='text' name='cod_veiculo'/>
<p><input type='submit' value='Salvar'/><input type='hidden' value='1' name='submitted'/>
</form>
    
asked by anonymous 25.10.2017 / 03:35

2 answers

2

This error can occur when a sequence has been opened and not closed (eg, braces, brackets, quotation marks).

See in your code in the line below that 3 single quotes are missing when inserting values:

'{$_POST['nome']}, '{$_POST['endereco']}, '{$_POST['cidade']},

When the correct one would be:

             FALTANDO                FALTANDO               FALTANDO
                 ↓                       ↓                     ↓
'{$_POST['nome']}', '{$_POST['endereco']}', '{$_POST['cidade']}',

And missing a double quotation mark on this line:

                                               FALTANDO
                                                  ↓
echo "<a href='listar_m.php'>Voltar à listagem</a>";
    
25.10.2017 / 04:36
0

The last echo "<a href='listar_m.php'>Voltar à listagem</a>; does not have the double quotes closing, completing, the insert command must have the quotation marks' before and after {$_POST['valor'}

    
25.10.2017 / 05:15