excuse me, do you know how to put a calendar in the form?
I try to put this code in my form but it has an error on line 2.
Anybody know? Please help me. Thank you

This is the calendar code :-

<?php
      $myCalendar = new tc_calendar("date5", true, false);
      $myCalendar->setIcon("calendar/images/iconCalendar.gif");
      $myCalendar->setDate(date('d'), date('m'), date('Y'));
      $myCalendar->setPath("calendar/");
      $myCalendar->setYearInterval(2000, 2015);
      $myCalendar->dateAllow('2008-05-13', '2015-03-01');
      $myCalendar->setDateFormat('j F Y');
      $myCalendar->setAlignment('left', 'bottom');
      $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year');
      $myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month');
      $myCalendar->setSpecificDate(array("2011-06-01"), 0, '');
      $myCalendar->writeScript();
?>

Dani AI

Generated

Common causes and quick fixes for the “error on line 2” when instantiating a calendar class (for reference: )

Common root causes: the calendar class file was not loaded before the new call, the include path is wrong (or wrong case on a case‑sensitive filesystem), there are stray characters or a UTF‑8 BOM before <?php, or a parse error inside an included file. As suggested, enable full error reporting first to see the exact message.

Enable errors (temporary, not for production):

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>

Checklist to resolve the problem (step‑by‑step)

  • Make sure the calendar library file is actually included before creating the object. Use a path based on the script directory (avoid fragile relative paths) and confirm the file name and directory case match the server.
  • After including, verify the class exists with class_exists('tc_calendar') before instantiating and fail fast with a clear message if it does not.
  • Inspect the included file for stray output or a BOM (these often cause errors reported on very early lines).
  • Open the browser console and view page source to confirm any client assets (JS/CSS/images) the calendar needs are loading.

If a client‑side solution is acceptable, a lightweight approach is to attach a JavaScript datepicker to a text input and submit it to PHP. Minimal example (HTML + jQuery UI init, then PHP reads $_POST['date']):

<form method="post">
  <input id="date" name="date" type="text">
  <input type="submit" value="Submit">
</form>

<script>
$(function(){
  $("#date").datepicker({ dateFormat: "dd MM yy" });
});
</script>

If the problem persists, post the exact PHP error message, the include/require line used, the script’s filesystem path relative to the calendar library, and the server PHP version. That information will let others (and / contributors) give precise next steps.

Recommended Answers

All 7 Replies

sorry for the typo at a title above.
What I was meant is 'put', not 'pun'

Member Avatar for Member #120589

You're using a calendar class - we don't know which one. Have you read the documentation? You do not state what the error is. Help us to help you.

why not used jquery ui?

how to used jquery ui? are we cannot use PHP?

Do you have this in your code..

require_once('calendar/classes/tc_calendar.php');

You need to insert the class for the Calender before using it.

You can look at this site for more information about how to use the calendar

http://www.triconsole.com/php/calendar_datepicker.php

Member Avatar for Member #120589

That site does indeed look like the source of the class - and a nice datpicker it is too - much nicer looking than the jquery ui one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.