4 Replies Latest reply on Jan 23, 2009 4:41 PM by Clive

    how to access randomkey code

    Clive Level 1
      Hi, <br />I'd like to be able to update a table to set a random value (16 chars) in a field using php code. <br />Does anyone know which include statement I would need and the assign code? <br />I did this many moons ago with asp as follows: <br /> <!--#include file="../../includes/tNG/tNG.inc.asp" --> <br /><% newstring = tNG_generateRandomString(32) %> <br /> <br />Any help appreciated <br />Thanks <br /> Clive
        • 1. Re: how to access randomkey code
          Günter Schenk Level 4
          Hi Clive,

          not quite sure if it works, but maybe you can try with a Custom Trigger like the following one that´s defined as BEFORE trigger:

          function Trigger_Custom(&$tNG) {
          $tNG->setColumnValue("columnname", tNG_generateRandomString(16));
          }

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: how to access randomkey code
            Clive Level 1
            Many thanks Günter
            Can you tell me what includes statement I need to be able to call tNG_generateRandomString?

            I'm trying to do a multiple update using this type of command.

            $query_rsData = "UPDATE tblMembers2 SET mSecKey = tNG_generateRandomString(16) WHERE tblMembers2.mID >'0'";

            But if fails as it can t find tNG_generateRandomString

            Thanks
            Clive
            • 3. Re: how to access randomkey code
              Günter Schenk Level 4
              ------
              Can you tell me what includes statement I need to be able to call tNG_generateRandomString?
              ------

              This function is defined in the file "includes/tng/tNG_functions.inc.php", so you´ll probably just need to add the relative path to this file to your form´s "require_once()" statements.

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: how to access randomkey code
                Clive Level 1
                Hello Günter

                Thanks for the advice again, I've included the file and I can assign a random value to a field and echo it. Perfect!

                However when I try usinging the function in my update query it says it still can't find it.

                $query_Recordset1 = "UPDATE tblMembers2 SET tblMembers2.mSecKey= tNG_generateRandomString(16) WHERE tblMembers2.mID>0";

                I realise this is not an ADDT specific query.

                Appreciate any help again
                Thanks Clive