Help My REGEX isn't working

Discussion in 'PHP' started by ladieballer2004, Aug 27, 2009.

  1. #1
    Here is my code
    
    $dataOK=TRUE;
    //enter rows into database
    foreach($_POST['Activity'] as $row=>$Act)
    {
    if (!empty($_POST['Activity'][$row]))
    { 
    
      $Activity=($Act);
      if(!empty($_POST['Activity'][$row]) && !ctype_alpha($_POST['Activity'][$row]))
      {echo '<b>One of your Activity columns is not in the proper format. Make Sure it is a word<br/>';$dataOK=FALSE;}
      
      $Position=($_POST['Position'][$row]);
      if (!empty($_POST['Position'][$row]) && !ctype_alpha($_POST['Position'][$row]))
      {echo '<b>One of your Position columns is not in the proper format. Make sure it is a word.<br/>';$dataOK=FALSE;}
      
      $StartDate=($_POST['StartDate'][$row]);
      if 
      (!empty($_POST['StartDate'][$row]) && !preg_match('/^(0[1-9]|1[0-2])-(19|20)\d{2}$/',$_POST['Startdate'][$row]))
      {echo '<b>One of your Start Date columns is not in the proper format. Make Sure it is MM-YYYY<br/>';$dataOK=FALSE;}
      
      $EndDate=($_POST['EndDate'][$row]);
      if (!empty($_POST['EndDate'][$row]) && !preg_match('/^(0[1-9]|1[0-2])-(19|20)\d{2}$/',$_POST['Startdate'][$row]))
      {echo '<b>One of your End Date columns is not in the proper format. Make Sure it is MM-YYYY<br/>';$dataOK=FALSE;}
      
      
      if($dataOK && !empty($_POST['Activity'][$row]) && !empty($_POST['Position'][$row])&& !empty($_POST['StartDate'][$row]) && empty($_POST['EndDate'][$row]) )
      {
    
      $involv = "INSERT INTO Involvement (Activity, Position, StartDate, EndDate,ULVID)
      VALUES ('$Activity','$Position','$StartDate','$EndDate','$ULVID')";
      }
       
     
    
      if (!mysql_query($involv,$con))
    {
        die('Error: ' . mysql_error());
      }
      echo "Record Added<br/>";
      }
    }
    
    Code (markup):
    Even if i put in a correct date format the parser is telling me that it's wrong. Can you see anything I messed up on? the date is supposed to be in MM-YYYY format.

    Thankyou in advanced
     
    ladieballer2004, Aug 27, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why are you making a new thread, you already made a thread for this if I remember correctly.
     
    premiumscripts, Aug 27, 2009 IP