views:

96

answers:

5

The following code:

<?php

if ($_SERVER['REQUEST_METHOD'] != 'POST'){
    $self = $_SERVER['PHP_SELF'];

?>

Generates this error:

Parse error: syntax error, unexpected $end in /home/idghosti/public_html/testground/mma/include/header.php on line 26

What is wrong with my code?

+6  A: 

You are missing the closing brace "}" after the statement:

$self = $_SERVER['PHP_SELF'];

It should be:

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
  $self = $_SERVER['PHP_SELF'];
}
?>
Peter
+1  A: 

You're missing a "}" before the end.

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST')
{
    $self = $_SERVER['PHP_SELF'];
} // This is missing
?>
Rich Adams
+1  A: 

You are most likely missing a curly bracket.

Your code should be:

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
  $self = $_SERVER['PHP_SELF'];
}
?>
Aron Rotteveel
+1  A: 

You need to close the curly bracket "}" before closing the php tag "?>"

EasyEcho
A: 

You got a curly bracket too much...

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST')
  $self = $_SERVER['PHP_SELF'];
?>
Erlend