View Single Post
  #2   (View Single Post)  
Old 16th August 2008
cajunman4life cajunman4life is offline
Real Name: Aaron Graves
Package Pilot
 
Join Date: May 2008
Location: Coolidge, Arizona
Posts: 203
Default

UPDATE: The code above was borked in that leaving the field blank would always fail. I at least fixed that:

Code:
  $must_match = "^[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}$";
  if((preg_match($must_match, $dte) && $dte) || (!$dte)) {
    if(!$dte) {
      $query = "INSERT INTO $table VALUES ('', NOW(), 'ajgraves', '$post');";
    } else {
      $query = "INSERT INTO $table VALUES ('', '$dte', 'ajgraves', '$post');";
    }
  } else {
    die("ERROR: You entered an invalid date");
  }
  mysql_query($query);
But if I actually enter a date, the correct format fails (so do incorrect formats, which is the intended effect )

I'm thinking it has to do with maybe the way I check for the space? "\ " perhaps isn't the best way. Maybe someone more versed in this can help me
__________________
I just saved a bunch of money on my car insurance by fleeing the scene of the accident!
Reply With Quote