We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37595
    • 6 Posts
    Hi everybody, so I got eform working with a snippet and add that data into a table my snippet call on Page resource:

    [!addinv!]
    [!eForm? &to=`[email protected]` &ccsender=`1` &formid=`itinv` &eFormOnBeforeMailSent=`addinv` &tpl=`itinventory` &report=`invRep` &subject=`IT Inventory Form` &thankyou=`invThanks`!]


    Snippet code:
    <?php
    function addinv( &$fields )
    	{
    		global $modx;
    		// Init our array
    		$dbTable = array();
    		$dbTable[date] = $fields[date];
    		$dbTable[location2] = $fields[location2];
    		$dbTable[bldgnumb] = $fields[bldgnumb];
    		$dbTable[aptnumb] = $fields[aptnumb];
                    $dbTable[techname] = $fields[techname];
                    $dbTable[email] = $fields[email];
                    $dbTable[rfirstname] = $fields[rfirstname];
                    $dbTable[rlastname] = $fields[rlastname];
                    $dbTable[inventorytype] = $fields[inventorytype];
                    $dbTable[other] = $fields[other];
                    $dbTable[itemnumb] = $fields[itemnumb];
                    $dbTable[wonumb] = $fields[wonumb];
                    $dbTable[comments] = $fields[comments];
    		// Run the db insert query
    		$dbQuery = $modx->db->insert($dbTable, 'invdb' );
    		return true;
    	}
    ?>


    ISSUE:
    It works fine and everything but when I added apostrophe on comments or any of my fields MODX returns me an parse error. Is funny cuz the " works perfectly. But for some reason when I add ' it doesn't work. Any ideas??
    Thank you!

    This question has been answered by randall. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Sounds like a server mod_security or suhosin configuration issue; these server settings can disallow such values being accepted via GET or POST from forms.
        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
        • 37595
        • 6 Posts
        Thanks for your reply, so this is the thing i can insert that character no problem from dbEdit or phpmyadmin.But for some reason it doesnt want to work from the snippet all characters are ok but that one.
        • discuss.answer
          • 36620
          • 65 Posts
          Not sure this will help but you could try:

          $dbTable[comments] = $modx->db->escape($fields[comments]);
            • 37595
            • 6 Posts
            That work like a champ thank you!!!!