I have a problem in this query, it consists of 3 sheets, one where I enter an email from a table to find a specific student, another where I change the course and another that modifies the course of the student table.
The problem is that I have a Syntax error according to MySQL and I do not see the error, I pass the code to you.
This is page 1, where I enter the student's email
<html>
<head>
<meta charset="UTF-8">
<title>Problema</title>
</head>
<body>
<form action="pagina17.php" method="post">
<br>
<label for="mail" id="e1">Introduzca el email del alumno</label>
<input type="text" name="mail"><br>
<input type="submit" value="buscar">
</form>
</body>
This is page 2, where I search if the student exists and the course is changed
<?php $conexion = mysqli_connect("localhost", "root", "", "base1")
or die("problemas con la conexion");
$registros = mysqli_query($conexion, "select * from alumnos where mail='$_REQUEST[mail]'")
or die("problemas con la consulta " . mysqli_error($conexion));
if ($regAlu = mysqli_fetch_array($registros)) {
?>
<form action="pagina18.php" method="post">
<input type="hidden" name="mailviejo" value="<?php echo $regAlu['mail'] ?>">
<select name="codigocurso">
<?php
$registros = mysqli_query($conexion, "select * from cursosprog")
or die("problemas "
. "en el select: " . mysqli_error($conexion));
while ($reg = mysqli_fetch_array($registros)) {
if (regalu['codigocurso'] == $reg['codigo']) {
echo "<option value=\"$reg[codigo]\" selected>$reg[nombrecurso]</option>";
} else {
echo "<option value=\"reg[codigo]\">$reg[nombrecurso]</option>";
}
}
?>
</select>
<br>
<input type="submit" value="Modificar">
</form>
<?php
} else {
echo "No existen alumnos con ese email";
}
?>
and here the final page
<?php $conexion = mysqli_connect("localhost", "root", "", "base1")or die("problemas "
. "con la conexion");
$registros = mysqli_query($conexion, "update alumnos "
. "set codigocurso=$_REQUEST[codigocurso] "
. "where mail='$_REQUEST[mailviejo]'") or
die("problemas en el select ggg" . mysqli_error($conexion));
echo "el curso fue modificado con éxito"
?>
<fieldset>
<a href="pagina16.php">Volver al formulario</a>
</fieldset>
The problem he gives me is this (I added it to ggg to locate the bug):
problems in the select gggYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[code] where mail="[email protected]' at line 1
what syntax error is it?