We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22574
    • 181 Posts
    Hey Guys,

    I have copied over the same eFrom2DB code I use on another site and its not working.

    I get this message above the form:
    Parse error: syntax error, unexpected T_PRIVATE in /home/moon/public_html/manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 21

    And when I click the forms button I get:
    Fatal error: Call to undefined function eForm2db() in /home/moon/public_html/assets/snippets/eform/eform.inc.php on line 377

    Here is the code I use:
    [!dbUpload!]
    [!eForm? &noemail=`true` &formid=`dbForm` &eFormOnBeforeMailSent=`dbUpload` &tpl=`dbForm`!]

    And the snippet
    <?php
    function dbUpload( &$fields )
    
          {
    
          global $modx;
    
          // Init our array
    
          $dbTable = array();
    
          $dbTable[name] = $fields[name];
    
          $dbTable[date] = $fields[date];
    
          $dbTable[rate] = $fields[rate];
    
          $dbTable[net] = $fields[net];
    
          // Run the db insert query
         if ($fields[type]==Private)
    	{					
          $dbQuery = $modx->db->insert($dbTable, 'customers' );
            }
          else $dbQuery = $modx->db->insert($dbTable, 'wotif' );
    
          return true;
    
          }
    ?>


    What have I buggered up?

    Or maybe is this site missing some php plugin etc?
      • 3749
      • 24,544 Posts
      "private" is a reserved word as of PHP5. Possibly there’s a function or variable with that name in the code. If so, changing it to a different spelling everywhere it occurs in all files would fix it for you (or switching to PHP4).
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Try using quotes
        if ($fields['type']=="Private")
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 22574
          • 181 Posts
          Thanks Bobray that was it!
            • 3749
            • 24,544 Posts
            Glad you got it sorted. smiley
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting