iPixel Posted September 14, 2010 Share Posted September 14, 2010 Can anyone tell me why $new_sDate ends up empty!? $search_sDate = $_GET['sDate']; #03-01-2010 #recreate dates for Oracle format $s_sD = explode("-",$search_sDate); if($s_sD[0] == 01) $new_sDate = $s_sD[1] . "-" . "JAN" . "-" . $s_sD[2]; if($s_sD[0] == 02) $new_sDate = $s_sD[1] . "-" . "FEB" . "-" . $s_sD[2]; if($s_sD[0] == 03) $new_sDate = $s_sD[1] . "-" . "MAR" . "-" . $s_sD[2]; if($s_sD[0] == 04) $new_sDate = $s_sD[1] . "-" . "APR" . "-" . $s_sD[2]; if($s_sD[0] == 05) $new_sDate = $s_sD[1] . "-" . "MAY" . "-" . $s_sD[2]; if($s_sD[0] == 06) $new_sDate = $s_sD[1] . "-" . "JUN" . "-" . $s_sD[2]; if($s_sD[0] == 07) $new_sDate = $s_sD[1] . "-" . "JUL" . "-" . $s_sD[2]; if($s_sD[0] == 08) $new_sDate = $s_sD[1] . "-" . "AUG" . "-" . $s_sD[2]; if($s_sD[0] == 09) $new_sDate = $s_sD[1] . "-" . "SEP" . "-" . $s_sD[2]; if($s_sD[0] == 10) $new_sDate = $s_sD[1] . "-" . "OCT" . "-" . $s_sD[2]; if($s_sD[0] == 11) $new_sDate = $s_sD[1] . "-" . "NOV" . "-" . $s_sD[2]; if($s_sD[0] == 12) $new_sDate = $s_sD[1] . "-" . "DEC" . "-" . $s_sD[2]; echo $new_sDate; Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/ Share on other sites More sharing options...
trq Posted September 14, 2010 Share Posted September 14, 2010 Obviously because $s_sD[0] never equals any of the values your looking for. You really ought to look at the date functions anyway, you have allot of redundant code. Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111002 Share on other sites More sharing options...
Pikachu2000 Posted September 14, 2010 Share Posted September 14, 2010 It works for me locally. Are you remembering to pass the GET var in the URL string when you test it? Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111005 Share on other sites More sharing options...
iPixel Posted September 14, 2010 Author Share Posted September 14, 2010 Obviously because $s_sD[0] never equals any of the values your looking for. You really ought to look at the date functions anyway, you have allot of redundant code. Actually $s_sD always equals the values i'm looking for, i echoes those separately before i test them and they always return a correct value. It's just $new_sDate that gives me the issue, the weirdest thing is that this used to work and just decided to annoy me right now. Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111007 Share on other sites More sharing options...
iPixel Posted September 14, 2010 Author Share Posted September 14, 2010 It works for me locally. Are you remembering to pass the GET var in the URL string when you test it? Yes the $_GET var is passed... i've been echoing all the values prior and post the $new_sDate creation and it only fails after the if statements. Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111009 Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2010 Share Posted September 14, 2010 Are you testing with an 08 or 09 month value? Be advised that leading zeros on numbers cause php to treat them as octal and 08 and 09 are invalid octal values. You would want to enclose the values in quotes so that they are treated as strings, especially the '08' and '09'. Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111013 Share on other sites More sharing options...
iPixel Posted September 14, 2010 Author Share Posted September 14, 2010 Are you testing with an 08 or 09 month value? Be advised that leading zeros on numbers cause php to treat them as octal and 08 and 09 are invalid octal values. You would want to enclose the values in quotes so that they are treated as strings, especially the '08' and '09'. LOL that worked, funny cause i bothered trying to do "08" with double quotes and that still failed, i guess single quotes do the trick! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.