i actually checked my code like a hundred times, but i cant find the error:
The error i get: Parse error: syntax error, unexpected $end in /home/tennox/public_html/php/kalender.php on line 46
I tried to do a function that calculates the easter sunday, in another script without all the other it just works, but in this one not. The other way round the same thing!
<?php
$year = isset($_POST['year']) ? intval($_POST['year']) : date('Y');
$months = array("", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
$days = array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
$ostern = getOsterSonntag($year);
?>
<form action="kalender.php" method="POST" target="_self">
<input type="text" name="year" value="<?php echo $year; ?>">
</form>
<table border="1" cellspacing="0">
<?php
for($y=0; $y<32; $y++) {
echo "<tr height=\"20\">";
for($x=1; $x<=12; $x++) {
echo "<td width=\"5%\">";
$date = strtotime("$y.$x.$year");
$day = date("d", $date);
$dayname = $days[date("w", $date)];
if ($y == 0) {
echo "<div align=\"center\"><b>$months[$x]</b></div>";
} elseif ($y < date("t",$date) && !($y == 30 && $x == 2)) {
if (date("w", $date) == 6 || date("w", $date) == 0)
echo "<b>";
echo "$day $dayname";
if ($date == $ostern)
echo "(Ostersonntag)";
if (date("w", $date) == 6 || date("w", $date) == 0)
echo "</b>";
} else {
echo " - ";
}
echo "</td>";
}
echo "</tr>";
}
?>
</table>
<?php
function getOsterSonntag($year) {
$a = $year % 19;
$b = $year % 4;
$c = $year % 7;
$k = floor($year / 100);
$p = floor((8*$k + 13) / 25);
$q = ($k / 4);
$d = (19*$a + ((15 + $k - $p - $q) % 30)) % 30;
$e = (2*$b + 4*$c + 6*$d + ((4 + $k - $q) % 7)) % 7;
$ostern = 22 + $d + $e;
if ($ostern > 31){
$ostern -= 31;
return strtotime("$ostern.4.$year");
} else
return strtotime("$ostern.3.$year");
}
?>
That error means that PHP has finished analyzing your code, but you forgot to close a symbol somewhere in your page.Its either you forgot to close a quote, bracket, parenthesis or comma.
Hope this helps.
This error usually means that you missed a }
. Check all your braces and make sure you have the same number of {
as }
- a code editor with bracket matching (such as Notepad++) can make this a lot easier.
In this part of your code, i think you should add { } for else.
$ostern = 22 + $d + $e;
if ($ostern > 31){
$ostern -= 31;
return strtotime("$ostern.4.$year");
} else
return strtotime("$ostern.3.$year");
also in this part put { } in this part like this :
if (date("w", $date) == 6 || date("w", $date) == 0) {
echo "<b>";
echo "$day $dayname";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With