rslnerd Posted November 27, 2008 Share Posted November 27, 2008 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 More sharing options...
awpti Posted November 27, 2008 Share Posted November 27, 2008 you're missing a quote here: $daysofweek = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday); Look carefully. Link to comment https://forums.phpfreaks.com/topic/134451-solved-page-loads-totally-blank/#findComment-700019 Share on other sites More sharing options...
rhodesa Posted November 27, 2008 Share Posted November 27, 2008 And next time, turn on error reporting...it will tell you where your error is Link to comment https://forums.phpfreaks.com/topic/134451-solved-page-loads-totally-blank/#findComment-700022 Share on other sites More sharing options...
rslnerd Posted November 27, 2008 Author Share Posted November 27, 2008 Sorry about that, but thanx for the help... Link to comment https://forums.phpfreaks.com/topic/134451-solved-page-loads-totally-blank/#findComment-700024 Share on other sites More sharing options...
coollog Posted November 27, 2008 Share Posted November 27, 2008 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> Link to comment https://forums.phpfreaks.com/topic/134451-solved-page-loads-totally-blank/#findComment-700026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.