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

    I have a problem which I would like to solve. I’m working on a website where webusers (webusers_attributes_extended table) can manage projects (webuser_projects table). They can see and update projects and this is done with webloginpe. Now here is the tricky part: When a new user comes to this website, they can create a project and in this form there is a part for there userregistration. How can the submit the project data to the project table and the registrationdate to the webuser_attributes_extended table? Can’t seem to figure this out. I have minor knowledge with PHP so any help is welcome laugh.

    Hope I have explained properly,

    Thanks!

    Rogier
      • 25586
      • 105 Posts
      After a few attempts I still cant get it to work.

      In the webloginpe.class.php you can find at line 601 the following code:

      		$newUserAttr = "INSERT INTO ".$web_user_attributes.
      		" (internalKey, fullname, email, phone, mobilephone, dob, gender, country, state, zip, fax, photo, comment) VALUES".
      		" ('".$key."', '".$fullname."', '".$email."', '".$phone."', '".$mobilephone."', '".$dob."', '".$gender."', '".$country."', '".$state."', '".$zip."', '".$fax."', '".$photo."', '".$comment."')";
      		$insertUserAttr = $modx->db->query($newUserAttr);


      I tried to modify it to the following code

      		$newUserAttr = "INSERT INTO ".$web_user_attributes.
      		" (internalKey, fullname, email, phone, mobilephone, dob, gender, country, state, zip, fax, photo, comment) VALUES".
      		" ('".$key."', '".$fullname."', '".$email."', '".$phone."', '".$mobilephone."', '".$dob."', '".$gender."', '".$country."', '".$state."', '".$zip."', '".$fax."', '".$photo."', '".$comment."')";
      		$insertUserAttr = $modx->db->query($newUserAttr);
      
      // ADDED THE STUFF BELOW
      
      		$newUserAttr = "INSERT INTO ".$web_projects.
      		" (internalKey, company_id, project_name) VALUES".
      		" ('".$key."', '".$company_id."', '".$project_name."')";
      		$insertUserAttr = $modx->db->query($newUserAttr);


      I’ve added the following code below line 428
      		$company_id = $modx->db->escape($modx->stripTags($_POST['company_id']));
      		$project_name = $modx->db->escape($modx->stripTags($_POST['project_name']));



      And it’s not working sad. This is what the sql outputs at submitting the registration form

      MODx encountered the following error while attempting to parse the requested resource:
      « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(internalKey, company_id, project_name) VALUES ('10', '', 'Project naam')' at line 1 »
            SQL: INSERT INTO (internalKey, company_id, project_name) VALUES ('10', '', 'Project naam') 


      Hope someone can help me out on this one smiley

      Rogier
        • 5340
        • 1,624 Posts
        You forgot the table name. Seems that $web_projects is empty so the INSERT doesn’t know where to put the data
          • 25586
          • 105 Posts
          I do have a table called web_projects... I think the problem lies at calling the $newUserAttr the second time.. So this part:

          		$newUserAttr = "INSERT INTO ".$web_projects.
          		" (internalKey, company_id, project_name) VALUES".
          		" ('".$key."', '".$company_id."', '".$project_name."')";
          		$insertUserAttr = $modx->db->query($newUserAttr);


          Someone knows how to correctly handle this behavior?

          Rogier
            • 4310
            • 2,310 Posts
            Where does the variable $web_projects get it’s value?
            If it’s not a variable but just the table name just use
            INSERT INTO `web_projects`