rsquaredpgh wrote:
> Ok. I've done away with the drop down boxes in favor of
a date picker. I'm now
> trying to convert the mm-dd-yyyy format to MySql format
(yyyy-mm-dd) when the
> form variable is passed. I'm trying to use the split
function to do this but so
> far I'm unsuccessful. Can someone look at my code and
tell if they see where
> the problem is?
There's not just one problem, but many. For a start, you
shouldn't be
adding slashes, but removing them. Next, you're using
different
variables for your default and form variables, so the form
variables
will never be used. There are also some extraneous characters
in the SQL
query.
The following code should do what you want:
<?php
$startDate_rsAV = '01/03/2007';
if (isset($_POST['startDate'])) {
$startDate_rsAV = (get_magic_quotes_gpc()) ?
$_POST['startDate'] :
stripslashes($_POST['startDate']);
}
list($sMonth, $sDay, $sYear) = split('[/.-]',
$startDate_rsAV);
// check that date elements are all numbers
if (is_numeric($sMonth) && is_numeric($sDay)
&& is_numeric($sYear)) {
$sDate = "$sYear-$sMonth-$sDay";
}
else {
echo 'Invalid start date';
exit;
}
$endDate_rsAV = '01/04/2007';
if (isset($_POST['endDate'])) {
$endDate_rsAV = (get_magic_quotes_gpc()) ? $_POST['endDate']
:
stripslashes($_POST['endDate']);
}
list($eMonth, $eDay, $eYear) = split('[/.-]',
$endDate_rsAV);
// check that date elements are all numbers
if (is_numeric($eMonth) && is_numeric($eDay)
&& is_numeric($eYear)) {
$eDate = "$eYear-$eMonth-$eDay";
}
else {
echo 'Invalid end date';
exit;
}
mysql_select_db($database_connGR, $connGR);
$query_rsAV = "SELECT * FROM calendar WHERE calDate >=
'$sDate'
AND calDate < '$eDate'";
$rsAV = mysql_query($query_rsAV, $connGR) or
die(mysql_error());
$row_rsAV = mysql_fetch_assoc($rsAV);
$totalRows_rsAV = mysql_num_rows($rsAV);
?>
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/