0

Here's my piece of code(full body code):

<body>
    <script type='text/javascript'>
        function AddEvent(Syear, Smonth, Sday, Eyear, Emonth, Eday, hallNumber){
            ...
        }
    </script>
    <?php
        function GetMonthByCoding($first , $second , $third) {
            ...
        }

        function GetDateByCoding($coding){
            ...
        }

        function GetDateFromLine($line){
            ...
        }

        $userid = '...';
        $magicCookie = 'cookie';

        $feedURL = "...";
        $sxml = simplexml_load_file($feedURL);

        foreach ($sxml->entry as $entry) {
            $title = stripslashes($entry->title);
            if ($title == "HALL") {
                $summary = stripslashes($entry->summary);
                $date = GetDateFromLine($summary);
                echo ("<script type='text/javascript' language='JavaScript'> AddEvent(" . $date['start']['year'] . ", " . $date['start']['month'] . ", " . $date['start']['day'] . ", " . $date['end']['year'] . ", " . $date['end']['month'] . ", " . $date['end']['day'] . "); </script>");
            }
        }
    ?>
  </body>  
  • AddEvent() is JavaScript function defined earlier.

    What I get in my browser is:
entry as $entry) { $title = stripslashes($entry->title); if ($title == "HALL") { $summary = stripslashes($entry->summary); $date = GetDateFromLine($summary); echo (""); } } ?>

Looks like it was an echo but as you can see there is no echo right in the middle of foreach.

Can anyone say what I am doing wrong?

4
  • We need to see more of the code before your loop before being able to spot the error Commented Dec 21, 2012 at 0:31
  • Add more code, i'm pretty sure it's a html comment issue Commented Dec 21, 2012 at 0:31
  • Is your server configured to handle PHP files? Commented Dec 21, 2012 at 0:34
  • 1
    You can remove language='JavaScript' since this attribute has been deprecated in favor of type Commented Dec 21, 2012 at 0:35

2 Answers 2

3

PHP is not installed, or it is not enabled, or the file is not a .php file or the server has not been told to recognise it as a file to parse.

Try View Source and you should see all your PHP code. The only reason part of it shows up is because everything from <?php to the first > is considered by the browser to be an invalid tag.

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

10 Comments

Well my server worked fine with Zend Framework for like 4 months and now I try to make smth on simple php and I cant make it. In addition Opera doesnt show any of that, just Chrome and Mozilla.
Opera probably parses the invalid HTML (since it's supposed to be PHP) differently from the other browsers. It's definitely a server issue - no PHP code should be shown to the browser at all.
Yeah. The view source stuff shows that php code is considered to be till -> but usually it is till ?>. So browser sees - as ? and I dont know how to fix this.
Is the file a .php file?
It's not seeing - as ?, it's seeing > as the match for <, to create one very long <?php [...] -> tag. The server is supposed to parse that before sending it to the browser.
|
0

I found the problem, it was in the name of variable sxml. I renamed it and the problem escaped.

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.