Pooty
Pooty

Reputation: 11

Why isn't PHP processing my PHP script?

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

Upvotes: 1

Views: 159

Answers (1)

Frank Farmer
Frank Farmer

Reputation: 39356

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.

Upvotes: 3

Related Questions