Jump to content

Parse error: syntax error


Styles2304

Recommended Posts

Ok, the error:

Parse error: syntax error, unexpected T_ECHO in /home/styles/public_html/calendar.php on line 67

 

And the code:

<?php
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];

if ($day == "")
  $day = date("j");
  
if ($month == "")
  $month = date("n");
//11  
if ($year == "")
  $year = date("Y");
  
  
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
//20
?>

<LINK REL=StyleSheet HREF="calendar.css" TYPE="text/css">

<table width='168' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td colspan="7" class="title">
      <font class="title">
      <center>
      <?php echo date("F");?>
      </center>
      </font>
    </td>
  </tr>

  <tr class="daylabels">
    <td class='head' width='24'>Sn</td>
    <td class='head' width='24'>Mn</td>
    <td class='head' width='24'>Tu</td>
    <td class='head' width='24'>Wd</td>
    <td class='head' width='24'>Th</td>
    <td class='head' width='24'>Fr</td>
    <td class='head' width='24'>St</td>
  </tr>

  <tr class="date">
<?php
//48
for ($i = 1; $i < $numDays + 1; $i++, $counter++) {
  $timeStamp = strtotime("$year-$month-$i");

  if ($i == 1) {
//Figures out when the first day of the month is
    $firstDay = date("w",$timeStamp);

    for($j = 0; $j < $firstDay; $j ++, $counter++)
      echo "<td> </td>";
  }
//59
  if($counter % 7 == 0)
    echo "</tr><tr class='date'>";

  if (date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
    echo "<td width='24' class='weekend'>$i</td>";

  if (date($i == date("d") && $month == date("m") && $year == date("Y")) 
    echo "<td width='24' class='today'>$i</td>";

  echo "<td width='24'>$i</td>";

}
?>

</table>

 

Line 67 is the 2nd to last echo statement where class='today' . . . can anyone see what the problem is? Or is the error elsewhere?

 

For that matter . . . does anyone know a good tutorial for creating a calendar in PHP?

Link to comment
Share on other sites

if (date($i == date("d") && $month == date("m") && $year == date("Y"))

if (date($i == date("d")) && $month == date("m") && $year == date("Y"))

 

Missing a ).

 

PS: You really should use {} in your conditional statements, what if you need to add another line in there and you forget to add them? Then you have to hunt down an error you're unsure about. It's good practice to add them by default.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.