.php error

I have this error: Parse error: syntax error, unexpected ‘else’ (T_ELSE), expecting end of file in C:\xampp\htdocs\DatosGradoDeLibertad\CrearUsuarios.php on line 32

Which causes not being able to use its function in unity well.

the code is the following:

1 <?php 2 include "Coneccion.php"; 3 4 $userName = $_POST['Usuario']; 5 $Email = $_POST['Correo']; 6 $Pass = hast("Sha256", $_POST['Contraseña']); 7 8 $sql = "SELECT Usuario From usuarios WHERE Usuario = '$userName'"; 9 $result = $pdo->query($sql); 10 11 if ($result->rowCount() > 0) 12 { 13 $data = array('Done' => false , 'Mensaje' => "Error, El nombre de usuario ya existe"); 14 Header('Content-Type: application/json'); 15 echo json_encode($data); 16 exit(); 17 } 18 19 else 20 { 21 $sql = "SELECT Correo From usuarios WHERE = '$Email'"; 22 $result = $pdo->query($sql); 23 24 if ($result->rowCount() > 0) 25 { 26 $data = array('Done' => false , 'Mensaje' => "Error, Correo ya existente"); 27 } 28 Header('Content-Type: application/json'); 29 echo json_encode($data); 30 exit(); 31 } 32 else 33 { 34 $sql = "INSERT INTO usuarios SET Usuario = '$userName', Correo = '$Email', Contraseña = '$Pass'"; 35 $pdo->query($sql); 36 37 $data = array('Done' => true, 'Mensaje' => "Usuario nuevo creado"); 38 Header('Content-Type: application/json'); 39 echo json_encode($data); 40 exit(); 41 } 42 ?>

This is PhP scrip. You need PhP server like Apache or relevant. Besides, Unity is not a support for PhP. You need go to PhP related forum. Not Unity.com

1 Like

Programming requires good concentration skill. Concentrate on your code and carefully check your {}. Repeat until bug is fixed. Next time use code tags on this forum.

1 Like

Code is difficult to read without formatting, but a quick look seems that you’re doing the following. Not sure if that was intended.

if()
{
}
else
{
}
else
{
}

1 Like