• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Write to external database

Write to external database 14 years 5 months ago #11963

Hi!

I´m trying to add a script called on form process that will write my form´s data into my external database (not same one where the RSforms tables are located)

I followed the example from here http://www.rsjoomla.com/customer-support/documentations/36-custom-scripts-and-customizations/122-mapping-form-submission-on-another-external-table.html

My code is this:
if(isset($_POST['form']['email'])) 
		{
 
			$database2 = $database;
 
			$database2 = new database("localhost", "user", "password", "myDB");
 
$database2->setQuery("INSERT INTO `testTable`(`NameInDB`,`SurnameInDB`,`AdressInDB`) VALUES ('$processform['NameField']', '$processform['SurnameField']', '$processform['AdressField']')");
 
$database2->query();
 
			}

I have no idea why it´s not working.
It´s either the connection to the database which is not declared propperly (username and password are correct), or the data from the fields in the form is not grabbed correctly (PROBABLY).

Anyone smart enought can help me out? sure there are lots of people with the same problem.

this is driving me nuts.:S
THANKS A LOT!!:laugh:
The administrator has disabled public write access.

Re:Write to external database 14 years 2 weeks ago #13261

  • makattak
  • makattak's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hey,

I've been trying to do the same thing with no luck using the sample code.

And database programming is what I do for a living(.net rather than php), but still no luck...

Did you ever work out how to make it work?

There were a couple of wierd things in the code:

'email' I presumed should be swapped for the actual name of your form!

'localhost' I wasn't sure wether to use machinename or database instance name

'optional' database prefix parameter, I wasn't sure wheter to just not supply it, suplly a blank string, or a null?

in the RS supplied code, some of the processform statements are wrapped in {}, and others are not....


I couldn't find any way of debugging the code...ie, no way to check any logs to see if the connect to the database had been successful

and I wanted to build the SQL in a avariable, and then be able to inspect it, but I couldn't work out how to output the variable anywhere so i could see what it had generated, and then was hoping to paste that statement into MySQL Workbench to see if the statement was valid....

So didn't have much luck really...

Please write back if you have any tips on debugging these php scripts inside RSForm...so far it's a bit like coding in the dark with your eyes shut....please help me turn on the lights!!
The administrator has disabled public write access.

Re:Write to external database 13 years 8 months ago #14373

Try this - it is great, reading from and writing to other databases. I have used it with no problems.

docs.joomla.org/How_to_connect_to_an_external_database

Good luck,

Bill Pattie
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!