Jump to content

Recommended Posts

I've been writing a little script to find the day of the week for any day... I finished it, uploaded it to my friend's server, and it loads totally blank... Here's the link: http://tech-shep.com/users/rslnerd/jsprogs/dow.php

 

Here's the code:

 

<html>
<head>
<title>Day of Week Finder</title>
<?php
$day = date("d");
$month = date("m");
$year = date("Y");
$today = $day;
$thismonth = $month;
$thisyear = $year;
$done = 0;
$daysofweek = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday);
$months = array("month number zero","January","February","March","April","May","June","July","August","September","October","November","December");
if ((isset($_GET[month]) && isset($_GET[day]) && isset($_GET[year])) &&  (checkdate($_GET[month],$_GET[day],$_GET[year]))
{
$month = $_GET[month];
$day = $_GET[day];
$year = $_GET[year];
$done = 1;
}
if ($done = 0)
{
$month = $realmonth;
$day = $realday;
$year = $realyear;
$month += 10;
$month %= 12;
if ($month == 0)
  $month = 12;
if (($month == 12) || ($month == 11))
  $year -= 1;
$year = $chyeary;
$year = $chyearc;
$chyeary %= 100;
$chyearc = ($chyearc - $chyeary)/100;
$total = $day + floor((13 * $month - 1) / 5) + $chyeary + floor($chyeary / 4) + floor($chyearc / 4) - (2 * $chyearc);
$total %= 7;
$dow = $daysofweek[$total];
$tense = "was";
if (($day == $today) && ($month == $thismonth) && ($year == $thisyear))
  $tense = "is";
elseif (($year > $thisyear) || (($year == $thisyear) && ($month > $thismonth)) || (($year == $thisyear) && ($month == $thismonth) && ($day > $today)))
  $tense = "will be";
}
if ($realyear < 1760)
$done = 2;
?>
</head>
<body>
<form action="dow.php" method="get">
<table border>
<tr bgcolor=black>
<th>
<input type="text" size=1 maxlength=2 name="month" value=<?php echo $month;?>></th><th>
<input type="text" size=1 maxlength=2 name="day" value=<?php echo $day;?>></th><th>
<input type="text" size=3 maxlength=4 name="year" value=<?php echo $year;?>></th></tr>
<tr bgcolor=blue><td>
<small>Month</small></td><td>
<small>Day</small></td><td>
<small>Year</small></td></tr><tr bgcolor=red><th colspan=3>
<input type="submit" value="Calculate"></th></tr></table>
</form><br/>
<?php
if ($done = 1)
echo "<h2>" . $day . " " . $months[$month] . " " . $year . " " . $tense . " a " . $dow . ".</h2>";
elseif ($done = 2)
echo "<h3>Date must be after 1760.</h3>";
else
echo "<h3>Enter any date after 1760.</h3>";
?>
</body>
</html>

 

I realise that my mistake is probably a stupid typo or something, but I'm new to PHP, so I really need help...

Thanks in advance to whomever helps me...

 

-rslnerd

Link to comment
https://forums.phpfreaks.com/topic/134451-solved-page-loads-totally-blank/
Share on other sites

Yea... Your problem is that you forgot a quotation ending...

 

$daysofweek = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","SaturdayHERE);

 

And a parenthesis ending on

if ((isset($_GET[month]) && isset($_GET[day]) && isset($_GET[year])) &&  (checkdate($_GET[month],$_GET[day],$_GET[year]))HERE

 

So, edited code should be

<html>
<head>
<title>Day of Week Finder</title>
<?php
$day = date("d");
$month = date("m");
$year = date("Y");
$today = $day;
$thismonth = $month;
$thisyear = $year;
$done = 0;
$daysofweek = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$months = array("month number zero","January","February","March","April","May","June","July","August","September","October","November","December");
if ((isset($_GET[month]) && isset($_GET[day]) && isset($_GET[year])) &&  (checkdate($_GET[month],$_GET[day],$_GET[year])))
{
$month = $_GET[month];
$day = $_GET[day];
$year = $_GET[year];
$done = 1;
}
if ($done = 0)
{
$month = $realmonth;
$day = $realday;
$year = $realyear;
$month += 10;
$month %= 12;
if ($month == 0)
  $month = 12;
if (($month == 12) || ($month == 11))
  $year -= 1;
$year = $chyeary;
$year = $chyearc;
$chyeary %= 100;
$chyearc = ($chyearc - $chyeary)/100;
$total = $day + floor((13 * $month - 1) / 5) + $chyeary + floor($chyeary / 4) + floor($chyearc / 4) - (2 * $chyearc);
$total %= 7;
$dow = $daysofweek[$total];
$tense = "was";
if (($day == $today) && ($month == $thismonth) && ($year == $thisyear))
  $tense = "is";
elseif (($year > $thisyear) || (($year == $thisyear) && ($month > $thismonth)) || (($year == $thisyear) && ($month == $thismonth) && ($day > $today)))
  $tense = "will be";
}
if ($realyear < 1760)
$done = 2;
?>
</head>
<body>
<form action="dow.php" method="get">
<table border>
<tr bgcolor=black>
<th>
<input type="text" size=1 maxlength=2 name="month" value=<?php echo $month;?>></th><th>
<input type="text" size=1 maxlength=2 name="day" value=<?php echo $day;?>></th><th>
<input type="text" size=3 maxlength=4 name="year" value=<?php echo $year;?>></th></tr>
<tr bgcolor=blue><td>
<small>Month</small></td><td>
<small>Day</small></td><td>
<small>Year</small></td></tr><tr bgcolor=red><th colspan=3>
<input type="submit" value="Calculate"></th></tr></table>
</form><br/>
<?php
if ($done = 1)
echo "<h2>" . $day . " " . $months[$month] . " " . $year . " " . $tense . " a " . $dow . ".</h2>";
elseif ($done = 2)
echo "<h3>Date must be after 1760.</h3>";
else
echo "<h3>Enter any date after 1760.</h3>";
?>
</body>
</html>

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.