Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Inserting participant from external sources into "ls_participants" with mysql

  • rother
  • rother's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #120542 by rother
Hello everyone,

I am trying to add survey participant into Limesurvey mysql db from Wordpress gravity forms plugin.
I want to allow participant to add themselves to Central participants database directly from Wordpress using forms from gravity forms.

Do you have any idea how can I do this? Here is my code so far:
The code is being integrated into wordpress theme's function.php

// Update limesurvey db along with gravity forms
add_action("gform_after_submission_4", "push_fields", 10, 2);
function push_fields($entry, $form){

$rfname = $entry["1"];
$rlname = $entry["2"];
$remail = $entry["4"];
$language = "en";
$blacklisted = "N";
$owner_uid = "1";
$created_by = "1";



$username ="username";
//$password = "somepass";
$password = "";
$host = "localhost";
$table = "ls_participants";

$con=mysqli_connect("$host","$username","$password","$table");

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"INSERT INTO table (firstname, lastname, email, language, blacklisted, owner_uid, created_by) VALUES ('$rfname','$rlname', '$remail', '$language', '$blacklisted', '$owner_uid', '$created_by')");
}
//End updating lime

Unfortunately I get an error message:

Warning: mysqli_connect(): (28000/1045): Access denied for user 'username'@'localhost' (using password: NO) in /www/yourdomain.com/www/root/wp/wp-content/themes/currenttheme/functions.php on line 741
Failed to connect to MySQL: Access denied for user 'username'@'localhost' (using password: NO)


Possible issues: Lime survey has been installed using softaculous from cPanel, so I don't know whether this installer sets password or not on the mysql db, and if sets what is it. I've tried without pass but the error message above occurs, I've tried with my admin pass but it doesn't work either.

Do you guys have any ideas what could be the issue?


Some additional info:
www.gravityhelp.com/documentation/articl...rm_after_submission/



Thank you,
Grigor Dimitrov
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 10 months ago #120554 by tpartner
You can find the DB credentials in limeSurveyRoot/application/config/config.php.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • rother
  • rother's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #120569 by rother
Thank you, this was very helpful, unfortunately I get another error:

Warning: mysqli_connect(): (42000/1044): Access denied for user 'opini_opl'@'localhost' to database 'ls_participants' in /www/opinify.solutions/www/root/wp/wp-content/themes/oneengine/lime.php on line 24
Failed to connect to MySQL: Access denied for user 'opini_opl'@'localhost' to database 'ls_participants'

Do you have any idea what may cause this since I am already using the right credentials? Do you think that the thing that I'm trying to do is possible at all? One more question, regarding this field "participant_id" how it is generated?

If not possible, is anyone aware of any workaround how can you allow respondents to register themselves directly into your central participants database?
The topic has been locked.
  • fransmarcelissen
  • fransmarcelissen's Avatar
  • Offline
  • Premium Member
  • Premium Member
More
8 years 10 months ago #120572 by fransmarcelissen
Hello,
A much better way to do this would be using the remote control api's ( manual.limesurvey.org/RemoteControl_2_API ) But as far as I see RC2 does not support the central paricipant db. May it will in the next release?
Have you tried to run the sql statements directly in mysql or in phpmyasmin? Probably then it is easier to see what's going wrong.
Frans
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose