I try to do a redirect with header
like this:
header('location:perfil.php?CodUsua=<?php echo $_SESSION['CodUsua']; ?>');
I get the following error:
Parse error: syntax error, unexpected 'UserCode' (T_STRING), expecting ',' or ')'
What would be the correct syntax?
If you're doing
header
, that means you're already in PHP. You don't need to reopen<?php
or write withecho
. That's why you get the syntax error.To fix it: just concatenate the session variable to the string you already have using the operator
.
: