Does anyone know why I get an error in if?

// Parse error : syntax error, unexpected token “if” in C:\xampp\htdocs\final\vistas\modulos\importar\Eliminar.php on line 7

<?php

// Usamos el comando "unlink" para borrar el fichero

unlink($_GET["name"]);

// Redirigiendo hacia atrás

header("Location: index.php " . $_SERVER["HTTP_REFERER"])

if(!headers_sent()) 

{ header('Location: index.php'); 

        exit; 

    }

?>

Seems like you forgot to add a semicolon after

header("Location: index.php " . $_SERVER["HTTP_REFERER"])

If this line looks like this:

header("Location: index.php " . $_SERVER["HTTP_REFERER"]);

It should be fine.

It is not, I thought the same

Oh yes it is!

PHP has found the start of your if statement before it expects to. The reason for that is that there’s no semicolon to terminate the previous header() line. Add the semicolon in like @jpajak says, make sure you’ve saved your work, and it’ll be fixed.

Sponsor our Newsletter | Privacy Policy | Terms of Service