We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12328
    • 9 Posts
    Well I tried doing print_r($dbTable); but still nothing shows up. It is very strange, it doesn’t show an error on the screen or in the System Events log. It just goes to a blank white screen.

    Also, here the table I’m using.
    -- 
    -- Table structure for table `modx_sponsor_user_info`
    -- 
    
    CREATE TABLE `modx_sponsor_user_info` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `status` varchar(50) NOT NULL default 'pending',
      `accepted` varchar(10) NOT NULL default 'no',
      `level` varchar(50) NOT NULL,
      `firstname` varchar(50) NOT NULL,
      `lastname` varchar(50) NOT NULL,
      `age` int(10) NOT NULL,
      `homephone` varchar(50) NOT NULL,
      `dayphone` varchar(50) NOT NULL,
      `email` varchar(50) NOT NULL,
      `address1` varchar(100) NOT NULL,
      `address2` varchar(100) NOT NULL,
      `city` varchar(100) NOT NULL,
      `state` varchar(50) NOT NULL,
      `zipcode` varchar(50) NOT NULL,
      `bike` varchar(50) NOT NULL,
      `number` int(10) NOT NULL,
      `type` varchar(50) NOT NULL,
      `class` varchar(50) NOT NULL,
      `years` int(10) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;


    Edit: Added table structure to post.
      • 33372
      • 1,611 Posts
      Try commenting out the insert query in your function as well as printing out the array and see if that shows you anything.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 12328
        • 9 Posts
        Quote from: ZAP at Aug 15, 2007, 02:20 PM

        Try commenting out the insert query in your function as well as printing out the array and see if that shows you anything.

        Ok, I tried that but no luck. Still just a blank white screen. >:(

        Here is the function I’m trying to use to print the array to the screen.
        <?php
        function sponsorInfo( &$fields )
        	{
        		
        		// Bring needed resources into scope
        		global $modx;
                        $table_name = $modx->getFullTableName( 'sponsor_user_info' );
        
        
        		// Init our array
        		$dbTable = array(); // key = DB Column; Value = Insert/Update value
        
        		// Insert field/value pairs to insert/update in our table
        		$dbTable['firstname'] = $fields['firstname'];
        		$dbTable['lastname'] = $fields['lastname'];
        		$dbTable['age'] = $fields['age'];
        		$dbTable['homephone'] = $fields['homephone'];
        		$dbTable['dayphone'] = $fields['dayphone'];
        		$dbTable['email'] = $fields['email'];
        		$dbTable['address1'] = $fields['address1'];
        		$dbTable['address2'] = $fields['address2'];
        		$dbTable['city'] = $fields['city'];
        		$dbTable['state'] = $fields['state'];
        		$dbTable['zipcode'] = $fields[zip'];
        		$dbTable['bike'] = $fields['bike'];
        		$dbTable['number'] = $fields['number'];
        		$dbTable['type'] = $fields['type'];
        		$dbTable['class'] = $fields['class'];
        		$dbTable['years'] = $fields['years'];
        			
                        print_r($dbTable);
        	
        		// Run the db insert query
        		// $dbQuery = $modx->db->insert( $dbTable, $table_name);	
        
        		return true;
        	}
        	// Return empty string
        	return '';
        ?>
          • 12328
          • 9 Posts
          Doh! Found what was wrong. I was leaving the return string empty. grin Fixed it and walla everything works like a charm. Thanks everyone for your help.
            • 10076
            • 1,024 Posts
            Quote from: bigimaginations at Aug 02, 2007, 11:09 AM

            Thanks for tutorial dospuntocero, it helped.

            I know they talked about his before, but I have little to know experience working with PHP/MySQl, so I was hoping someone could explain in more detail how to return the results of the database table so they can be displayed on an actual page of the website. Thanks.

            Any response to this question? Or perhaps a usefull link? Or do I really need to study MySQL to understand what to do?

              • 23491 ☆ A M B ☆
              • 1,056 Posts
              Quote from: Frank at Aug 30, 2007, 05:10 PM


              Or do I really need to study MySQL to understand what to do?

              Fortunately, this will not be required! However, some general knowledge of PHP and MODx’s DBAPI class definitely could not hurt.

              eForm2db is mainly exposure to the MODx DBAPI mashed up with eForm’s event functions, illustrating how to combine the 2 into a manageable solution for interfacing with the database via HTML form submissions.

              In all reality, familiarizing yourself with the DBAPI should get you pretty close if all you need to do is read/write rows to your MySQL tables...


              More on the DBAPI:
              http://www.modxcms.com/dbapi.html
                Mike Reid - www.pixelchutes.com
                MODx Ambassador / Contributor
                [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                ________________________________
                Where every pixel matters.
                • 15716
                • 57 Posts
                First off, I love eForm2db...genius! Works perfect for me and what I want to do.

                Second, I’ve got some questions...
                1.) I get an error when I want to write a name with an apostrophe (ie, "O’Brien") to the database. Any way to fix this or get around it?

                2.) **DOES NOT RELATE DIRECTLY TO EFORM2DB** Do you know anything about temporary linking through ModX? Basically, I send an email to whoever fills out the form (and I store their info in the DB) and in that email they get a download link. I have no idea how to do this but from what I’ve researched it is something like:
                Point the url to a delivery script, and store the parameter in a database.
                Store some form of unique but identifiable URL-ending.
                You then provide the custmer with their download link, built from the database entry:
                http://www.example.com/cgi-bin/[email protected]
                When somescript.cgi is called it looks up the entry in the database, if it exists, open the file from a secret location and print it to the browser. The actual location of the file is never revealed. If the entry doesn’t exist, it’s expired and display your favorite too bad, so sad message...
                I know this doesn’t relate, sorry about that...
                Thanks anyway!
                  • 23491 ☆ A M B ☆
                  • 1,056 Posts
                  Quote from: Kev at Aug 31, 2007, 09:41 AM

                  First off, I love eForm2db...genius! Works perfect for me and what I want to do.

                  Second, I’ve got some questions...
                  1.) I get an error when I want to write a name with an apostrophe (ie, "O’Brien") to the database. Any way to fix this or get around it?



                  //<?php
                  // Just an example
                  $tblCol = ’last_name’;
                  $dbTable[ $tblCol ] = addslashes( trim( $fields[ $tblCol ] ) );



                  duh! How did I forget about the escape method!! Thx, ZAP
                    Mike Reid - www.pixelchutes.com
                    MODx Ambassador / Contributor
                    [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                    ________________________________
                    Where every pixel matters.
                    • 33372
                    • 1,611 Posts
                    I think that it’s a good idea to use the MODx API for this:
                    $string = $modx->db->escape($string);

                    More info here.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 3493
                      • 66 Posts
                      Now this is great! Combining the powerful eForm system with database manipulation just puts the pieces together laugh
                      I’m up for altering a different database than the one MODx uses, so I guess I’d have to go around the MODx DBAPI and create a custom mySQL-call instead. Any idea how to accomplish this? Would it be just to replace
                      $dbQuery = $modx->db->insert( $dbTable, $table_prefix . 'insertTableName' );	

                      ...With a simple mySQL-query?

                      Thanks, and keep up the good work!