2 Replies Latest reply on Oct 14, 2008 11:13 AM by (alterity)

    using php string function on update and/or insert

      So, for instance, I want to place a month/day in a column but I want the insert or update to strip out any forward-slash character that might be submitted.

      How do I get str_replace() to be applied on insert or update to prevent the insertion of a forward-slash.

      I am having trouble figuring out to what I should apply function. There's nothing in the form's value field and even if I echo in a variable or something like this:

      echo $row_rssubscription_payment_copy['expirationDate'];

      I have trouble "seeing" what the syntax should be. My guesses are all wrong.

      Will someone please lend a hand.

      Thanks very much!
        • 1. Re: using php string function on update and/or insert
          Günter Schenk Level 4
          Hi alterity,

          if you´d use ADDT´s datepicker, you wouldn´t need to worry about that :-)

          honestly, if a column like "expirationDate" is supposed to store the year-month-day value in a mysql compatible format, I can´t think of any reason to not use the datepicker.

          However it´s possible to apply stuff like that to a certain transaction value before it´s getting submitted to a table -- here´s a str_replace example which would replace a forward slash (/) with a hyphen:

          $tNG->setColumnValue("columnname_here", str_replace('/','-',$tNG->getColumnValue("columnname_here")));

          All you´d need to do, is to embed such things in a Custom Trigger and make sure it´s defined as BEFORE trigger.

          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: using php string function on update and/or insert
            Level 1
            Gunter, you are the best.

            My example was just a for instance. I have a cc expires column that already contains data like 01/08. I just started playing around with str_replace() to try and attach the function to an insert or update record for that column and couldn't figure out how to do it.

            But as usual, you've come through in a flash! Thanks for the help.