0

I really can't find the error. Here is my code:

<?
    // Action: add news
    if( array_key_exists('create_new', @$_POST) )
    {
?>
  ...
<?
        exit();
    }
?>

Before this my problem was in construction: <?=...;?> My web server (Apache) did not understand the syntax so I rewrote the method without it, but now I really can't find a solution.

5 Answers 5

1

Add a space before the ? and after the ; here:

$_SERVER['REQUEST_URI'];?>

Replace all <? by <?php

Sign up to request clarification or add additional context in comments.

3 Comments

Okay, but why? All time before I used <? not <?php. Could I enable this?
Its in the php.ini search for short_tags or similar.
I don't see how this can be a short tags issue: the implication of changing <? to <?php is that it's in short tags form and therefore not being parsed by PHP, which is obviously not the case as otherwise the code would just be returned to the browser, as opposed to the error "unexpected $end in php" (which I assume is what the OP is getting, according to the question title).
1

@$_POST should just be $_POST

Comments

0

you should you the alternate if syntax:

<?php
// Action: add news
if( array_key_exists('create_new', @$_POST) ):

?>
...
<?php
  exit();
  endif;
?>

it's also better to use the

Comments

0

You're apparently missing a close brace. I hate to say it, but without the complete code, it's pretty hard for us to tell you where the problem is... so either I think we need to see the complete code, or you'll have to sit down with a decent editor and trace the opening and closing braces.

Comments

0

Although it's a bit odd, if you put a semi-colon after a brace in this kind of scenario, it'll get rid of your errors.

<?
    // Action: add news
    if( array_key_exists('create_new', @$_POST) )
    {
?>
  ...
<?
        exit();
    };
?>

Note the second to last line now has a semi-colon AFTER the brace.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.