SouthFace Posted July 22, 2016 Share Posted July 22, 2016 Ok I haven't followed the code 100% by which I mean only that I didn't include the XHTML parts in the <!DOCTYPE> tag. I understand that this is not vital however. Other than that I think I have followed it correctly. I keep getting http error 500 in the browser however when I try to load it. However other php scripts seem to load fine so I don't think it's a problem with MAMP.Here is my code: <!DOCTYPE html> <html> <head> <meta charset="utf-8" http-equiv="Content-Type" content="text/html"> <title>Calendar</title> </head> <body> <form action="calendar.php" method="post"> <?php # Script 2.6 - Calendar.php //This script makes 3 pulldown menus //For an html form: months, days, years. //make months array $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); //make the days and years array $days = range (1, 31); $years = range (2011, 2021); //make the months pull down menu: echo '<select name="month">'; for each ($months as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; //make the days pull-down menu: echo '<select name="day">'; foreach ($days as $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; //make the years pull-down menu: echo '<select name="year">'; foreach ($year as $value) { echo "<option value=\"$value\"> $value</option>\n"; } echo "</select>"; ?> </form> </body> </html>It's probably something incredibly obvious and embarrassing but any help would be gratefully received. I'm going to skip ahead and read the section of bug fixing while I wait for a response so maybe I will find the answer there. Thanks in advance. Link to comment Share on other sites More sharing options...
SouthFace Posted July 22, 2016 Author Share Posted July 22, 2016 I think I might have found the problem I'm being dense. Link to comment Share on other sites More sharing options...
larryjsr Posted July 27, 2016 Share Posted July 27, 2016 (edited) Line 24..... You have for each, this should read foreach Line 20... You have $year, but on line 38 you are calling $years. Change line 38 to read as follows: foreach ($years as $value) { Hope this helps. Edited July 27, 2016 by larryjsr Link to comment Share on other sites More sharing options...
SouthFace Posted July 27, 2016 Author Share Posted July 27, 2016 Yeah thanks I did finally get it working. Link to comment Share on other sites More sharing options...
Ekkebert Posted September 15, 2016 Share Posted September 15, 2016 Yeah thanks I did finally get it working. All it takes is one little mistake to mess everything up right? Link to comment Share on other sites More sharing options...
Recommended Posts