1

I am trying to include a calendar into my website that I am designing. Not really knowing how to create an event calendar, I chanced upon this calendar that was created using javascript. However, I can't seem to get it working.

Here is the code, in a file with an extension of .html:

<head>  
<script type="text/javascript" src="date/calendar.js"></script>
</head>

<body>
Date
<form action="somewhere.php" method="post">
    <?php
    //get class into the page
    require_once('date/classes/tc_calendar.php');

    //instantiate class and set properties
    $myCalendar = new tc_calendar("date1");
    $myCalendar->setDate(date("d"), date("m"), date("Y"));
    $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-14", "2011-04-25"), 0, "month");

    //output the calendar
    $myCalendar->writeScript();
    ?>
</form>
</body>

It appears that the PHP in the webpage isn't being processed. What's visible in the browser is:

Date
setDate(date("d"), date("m"), date("Y")); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-14", "2011-04-25"), 0, "month"); //output the calendar $myCalendar->writeScript(); ?>

I do not understand what is wrong here.

I'd appreciate any help.

Cheers,

Josh

5
  • 2
    What's the file extension on the file? Are other php scripts in the same directory working as expected? Commented Oct 27, 2011 at 20:43
  • 3
    It would seem the web server isn't processing the file as a PHP script. Commented Oct 27, 2011 at 20:44
  • it's a html file, and my other php scripts seem to be working fine. Commented Oct 27, 2011 at 20:46
  • 1
    @user1005690 it has to be either a PHP file or you need to reconfigure your server to treat HTML files as PHP files. Commented Oct 27, 2011 at 20:47
  • @user1005690: Note that clarifications should be edited into the question, not posted as comments. Questions and answers should be self-contained, not requiring someone to read the comments. Also, please pick a meaningful name. Among other benefits, you'll be able to receive at-replies. Commented Oct 27, 2011 at 21:22

1 Answer 1

3

Web servers generally won't parse php in .html files. Change the file extension from .html to .php

You could force your server to parse PHP in html files as well as PHP files (with something like AddHandler php5-script .html for apache), but that's generally bad practice.

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

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.