We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31037
    • 358 Posts
    There is an error in PPP that causes that id error, I have it fixed in my local copy of PPP. It’s realy easy to fix, I’ll give you instructions for that together with an updated copy of Efreg as soon as I can!

    You will not need to do something to the database, it’ll work after these fixes.
      • 26975
      • 26 Posts
      I’ve been playing with PPP and eFreg, and they are really great. However, I’m encountering the same issue as mentioned above, and the addition of a phone field doesn’t solve my problem. Am I missing something?

      I just took a look at the code, and it seemed like this would be an okay solution:

      // save user attributes
      
      		$values = '';
      		$valuesFields = '';
      		$preparedFieldNames = '';
      		$preparedTableFields = '';
      		
      		if(is_array($efreg_inputs_opt)){
      				$k=0;
      				foreach($efreg_inputs_opt as $name => $value) {
      					$valuesFields[] = $name;
      					$values[] = trim($value);
      					$values[$k] = "'" . $values[$k] . "'";
      					$k++;
      				}
      				$preparedFieldNames = ", " . implode(', ', $valuesFields);
      				$preparedTableFields = ", " . implode(', ',$values);
      		}
      		
          $sql = "INSERT INTO ".$modx->getFullTableName("web_user_attributes")." (internalKey, fullname, email $preparedFieldNames) 
                  VALUES($key, '$fullname', '$email' $preparedTableFields);";


      Any reason it would be bad?
        • 26975
        • 26 Posts
        Okay, so doing that hid the error... but the data isn’t being put in the table either. Is there a fix for this already? I’m going to take a deeper look into the code soon.
          • 26975
          • 26 Posts
          I replaced
          if ($_POST[$input_prefix.'country']) $country = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'country']));
          	if ($_POST[$input_prefix.'state']) $state = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'state']));
          	if ($_POST[$input_prefix.'zip']) $zip = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'zip']));
          	if ($_POST[$input_prefix.'phone']) $efreg_inputs_opt['phone'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'phone']));
          	if ($_POST[$input_prefix.'mobilephone']) $efreg_inputs_opt['mobilephone'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'mobilephone']));	
          	if ($_POST[$input_prefix.'dob']) $efreg_inputs_opt['dob'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'dob']));	
          	if ($_POST[$input_prefix.'gender']) $efreg_inputs_opt['gender'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'gender']));		
          	if ($_POST[$input_prefix.'fax']) $efreg_inputs_opt['fax'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'fax']));		
          	if ($_POST[$input_prefix.'photo']) $efreg_inputs_opt['photo'] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.'photo']));			
          	if ($_POST[$input_prefix.'comment']) $efreg_inputs_opt['comment'] = $modx->db->escape($_POST[$input_prefix.'comment']);	

          with

          $efreg_extra_inputs = array('country','state','zip','phone','mobilephone','dob','gender','fax','photo','comment');
          	foreach($efreg_extra_inputs as $input => $putInArray){
          		if($_POST[$input_prefix.$input]){ 
          			 $efreg_inputs_opt[$input] = $modx->db->escape($modx->stripTags($_POST[$input_prefix.$input]));
          		}
          	}


          and now all seems to be golden. I’m not sure what exactly was broken, but this works for me in my limited testing.
            • 31037
            • 358 Posts
            Sheeley, sorry for not answering earlier, but I’ve been away for about two weeks. But it seems that you found the solution by your self, and also managed to shorten down the code while doing it! smiley

            There where two problems as you correctly found out:

            Error #1: My code *required* that there would be at least one field added to the web_user_attributes table, if not the sql query would end with a comma, not good! Stupid misstake by me! smiley This was the problem Soshite also was exposed to.

            Error #2: I’ve somehow missed to put the country, zip, and state field into the input_opt array, how could I ever make such a stupid misstake? huh

            I’ll update the code tomorrow! Thanks very much for finding this out!

            @Soshite: I’m verry sorry for leaving you for two weeks without a solution, but I had to take care of some unexpected stuff in "real life".

            New version comming soon.
              • 31037
              • 358 Posts
              Now I have updated eFreg to version 0.2 to solve some issues. Haven’t tested as much as usual, but I believe it *shold* work. smiley

              Thanks to Soshite and Sheeley for helping me debugging this script.

              Please let me know if it works (or not).

              To upgrade, just replace the installed efreg.inc.php with the file included in the archive.

              /Uncle68

              (File attached to first post.)

                • 26975
                • 26 Posts
                Hey Uncle, glad I could help. Even happier you’d already created these two snippets, it’s much easier to just debug than to create a whole new solution. smiley
                  • 28033
                  • 925 Posts
                  Don’t worry, I fully understand about stuff in real life getting in the way. Happened to me many of times before.

                  I’m going to be revamping my site w/ a new layout, which means I’ll be able to test to check if this fixed it. smiley
                    My Snippets
                    -> PopUpChunk v1.0
                    • 17883
                    • 1,039 Posts
                    german language file attached. Will report later about my attempt to install it wink
                      • 28033
                      • 925 Posts
                      Nothing code-breaking, but the snippet.efreg.txt file didn’t update the version number to 0.2 Beta.

                      Nothing a few keys can’t fix, though. Thankfully that won’t affect anything. laugh
                        My Snippets
                        -> PopUpChunk v1.0