1

I am new to php and I have a problem with the following code:

$ID = $_POST["first_name"]
$EXT = ".html"
$DOMAIN = "blabla.com/membersarea/"
$URL =  ($DOMAIN . $ID . $EXT)
header("location: http://".$URL);

Here is the error I'm getting:

Parse error: syntax error, unexpected T_VARIABLE 

The error is on line 3:

$EXT = ".html"

So my question is: is the error because of a point in a php variable?

3 Answers 3

7

You missed semicolon ; in your code. Each statements should ends with semi-colon ;

<?php
  $ID = $_POST["first_name"];
  $EXT = ".html";
  $DOMAIN = "blabla.com/membersarea/";
  $URL =  ($DOMAIN . $ID . $EXT);
  header("location: http://".$URL);
?>
Sign up to request clarification or add additional context in comments.

2 Comments

And every other line apart from the last as well.
even after $DOMAIN = "blabla.com/membersarea/"
1

You need to use ; semi-colon delimiter to say php that this is the end of this line...

<?php
   $ID = $_POST["first_name"];
   $EXT = ".html";
   $DOMAIN = "blabla.com/membersarea/";
   $URL =  ($DOMAIN . $ID . $EXT);
   header("location: http://".$URL);
?>

Also use exit; after header()

<?php
   $ID = $_POST["first_name"]; /* Sanitize your data, atleast use mysqli_real_escape_string()*/
   $EXT = ".html";
   $DOMAIN = "blabla.com/membersarea/";
   $URL =  ($DOMAIN.$ID.$EXT); /* Also don't leave any spaces here */
   header("location: http://".$URL);
   exit;
?>

Comments

0

you have to put semi-colon at the end of each line to tell php its the end of line and you are going to start next one. So, in your code put semi-colon(;) in the first four lines.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.