Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-24-2005, 06:45 PM test this plz?
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
I'm reading a tutorial in a book on how to make a basic calander, I wrote exactly how they have it but i keep getting these 2 lines on the top of my page that say:

Notice: Undefined index: month in c:\program files\easyphp1-8\www\mycoding\listing22.php on line 3

Notice: Undefined index: year in c:\program files\easyphp1-8\www\mycoding\listing22.php on line 3

I this it might be because of this EasyPHP that i'm running but i wanted to see if someone else got the same errors using a real install.

Everything comes on the page as its supposed to just with those messages.

Code:
<?php
define("ADAY" , (60*60*24));
if (!checkdate($_POST['month'], 1, $_POST['year']))  {
	$nowArray = getdate();
	$month = $nowArray['mon'];
	$year = $nowArray['year'];
}else {
	$month = $_POST['month'];	
	$year = $_POST['year'];
}
$start = mktime (12, 0, 0, $month, 1, $year);
$firstDayArray = getdate($start);
?>


<!-- =====================================starting html form =========================-->

<html>
<head>
	<title><?php echo" Calendar: " .$firstDayArray['month'] ." ".$firstDayArray['year'] ?></title>
<head>
<body> 
<!-- =====================================Month Dropdown Menu =========================-->
<form method="post" action="<?php echo "$_SERVER[PHP_SELF]"; ?>">
<select name="month">
<?php
$months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
for ($x = 1; $x <= count($months); $x++)	{
	echo "<option value=\"$x\" ";
	if ($x == $month){
	echo " SELECTED";
	}
	echo ">".$months[$x-1]. " ";
}
?>
</select>
<!-- =====================================Year Dropdown Menu =========================-->
<select name="year">
<?php
for ($x=1980; $x<=2010; $x++)	{
	echo "<option";
	if($x == $year) {
		echo "SELECTED";
		}
	echo ">$x";
}
?>
</select>
<input type="submit" value="Go!">
</form>
<br>
<!-- =====================================Calander =========================-->
<?php
  $days = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
  echo "<TABLE BORDER=1 CELLPADDING=5<tr>\n";
	foreach ($days as $day)
	{
		echo "<TD BGCOLOR=\#CCCCCC\" ALIGN=CENTER><strong>$day</strong></td>\n";
	}
for ($count=0; $count < (6*7); $count++)
{
	$dayArray = getdate($start);
		if (($count%7) == 0) 
	{
			if ($dayArray['mon'] != $month)
		   {
			break;
		   } 
		else 
		   {
		echo "</tr><tr>\n";
	        	    }
	}
	if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month) 
		     {
		echo "<td>&nbsp;</td>\n";
		     } 
		else 
		        {
		  echo "<td>".$dayArray['mday']." &nbsp;&nbsp</td>\n";
		  $start +=ADAY;
		           }
}
echo "</tr></table>";
?>
 
</body>
</html>
The_Anomaly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-24-2005, 06:52 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Notices should only come up on a development server. Lazy coders will ignore references which they know will throw a notice. This is especially problematic when the script includes a header redirect as it simply wont work. Notices can also disrupt CSS loading correctly in some cases.

If you want the notices to disappear, change the if condition to:
Code:
if(isset($_POST['month']) && isset($_POST['year'])){
if (!checkdate($_POST['month'], 1, $_POST['year']))  {
	$nowArray = getdate();
	$month = $nowArray['mon'];
	$year = $nowArray['year'];
}else {
	$month = $_POST['month'];	
	$year = $_POST['year'];
}
}
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 06-24-2005, 09:28 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
I just wanted to make sure the notices wouldnt show up if i was coding something and threw it up on a server. If i understand you correctly if i coded something and had those errors using easyPHP then took the same thing and threw it up on a server the people going to that site would not be able to see the notices.

I also notice something weird is happening in the year drop down. 2004 and 2005 are stuck together and displays as 20042005. any idea's what that could be from?

Last edited by The_Anomaly; 06-24-2005 at 09:55 PM..
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to test this plz?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22494 seconds with 12 queries