...

View Full Version : date - help debug



esthera
10-13-2004, 06:27 PM
I am using the following code to make select boxes with a date (and my date selected) I thought it was working but now the month is not showing up at all. Please help me debug.

Here's the code


<?php
$min = explode('-', date('Y-m-d'));
$max = explode('-', date('Y-m-d', mktime(0, 0, 0, ($min[1] + 3), $min[2], $min[0])));
$dtremove= explode('-', $datetoremove);
$year=$dtremove[0];
$month=$dtremove[1];
$day=$dtremove[2];
?>
<tr><td><b>Date to Remove </b><font size=small>Day/Month/Year</font><br></td>
<td>
<select name="day" id="day">
<?php
for($j = 1; $j <= 31; $j++)
{


if($j== $day){ ?>
<option selected value="<?php echo $j; ?>"><?php echo $j; ?></option>
<?php
}else{
?>
<option value="<?php echo $j; ?>"><?php echo $j; ?></option>
<?php
}
}
?>
</select>
<select name="month" id="month">
<?php
for($i = $min[1]; $i <= $max[1]; $i++)
{

if($i== $month){ ?>
<option selected value="<?php echo $i; ?>"><?php echo date('F', mktime(0, 0, 0, $i, 1, $min[0])); ?></option>
<?php
}else{
?>
<option value="<?php echo $i; ?>"><?php echo date('F', mktime(0, 0, 0, $i, 1, $min[0])); ?></option>
<?php
}


}
?>
</select>

<select name="year" id="year">
<option value="<?php echo $min[0]; ?>"><?php echo $min[0]; ?></option>
<?php if($max[0] != $min[0]){ ?>
<option selected value="<?php echo $max[0]; ?>"><?php echo $max[0]; ?></option>
<?php } ?>
</select>

marek_mar
10-13-2004, 06:56 PM
Ok if it is really debug you want then:
Notice: line 5 - Undefined variable: datetoremove
Notice: line 7 - Undefined offset: 1
Notice: line 8 - Undefined offset: 2
Side note: Undefined offset is just like a undefined variable but in an array eg. :


$dtremove[1] = UNSET

esthera
10-13-2004, 07:25 PM
$datetoremove is defined above the code.
the year and day is working. It's just month that is not working.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum