Says that it writes to mysql but does not save to the database

1

Form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cadastrar Associado</title>
<style type="text/css">

</head>

<body>
<table width="625" border="0" align="center">
   <tr>
        <td width="69">
        <fieldset>
        <legend><font size="3" face="verdana"><strong>Cadastro de Associado</strong></font> </legend>
                  <span class="style1"><font size="1" face="verdana"><b>Todos os campos são obrigatórios!</b></font></span><br><br>
<form id="cadastro" name="cadastro" method="post" action="grava_matricula_mensalidade.php">
  <font size="2" face="verdana"><b>
  <table width="625" border="0">
    <tr>
      <td width="69">Matrícula:</td>
      <td width="546"><input name="matricula" type="text" id="matricula" size="4" maxlength="4" /></span></td>
    </tr>
    <tr>
      <td colspan="2"><p>
      <br>
        <input name="cadastrar" type="submit" id="cadastrar" value="Cadastrar" /> 
        <br><br>
        </td>
    </tr>
  </table>
  </font></b>
</form>
    </fieldset>
        </td>
    </tr>
</table>

</body>
</html>

grava_matricula_mensalidade.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php 

$matricula = $_POST['matricula'];


$conexao1 = mysql_connect("localhost","root","123");
if (!$conexao1)
    die ("Erro de conexão com localhost, o seguinte erro ocorreu -> ".mysql_error());

$banco = mysql_select_db("coloniaam34",$conexao1);
if (!$banco)
    die ("Erro de conexão com banco de dados, o seguinte erro ocorreu -> ".mysql_error());



$query = ("INSERT INTO mensal_anual (matricula) VALUE ('$matricula')");

mysql_query($query,$conexao1);

echo "Seu cadastro foi realizado com sucesso!<br>Agradecemos a atenção.";
?>
<p>

<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=cadastrar_matricula.html">
</body>
</html>

NOTE: It says that you registered correctly, but not saved in BD mysql.

Would anyone know the error?

    
asked by anonymous 04.05.2018 / 16:00

1 answer

5

Syntax error

$query = ("INSERT INTO mensal_anual (matricula) VALUES ('$matricula')");

It is VALUES and not VALUE

    
04.05.2018 / 21:05