TOPIC:

Problem populating fields using SQL 11 months 2 weeks ago #237208

  • Topic Author
  • baileynp
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 76
  • Thanks: 1
Hi

I'm trying to populate the fields on my form using SQL, but I'm getting syntax errors.

I have a simple test form with one textfield named bfTXT.

My test script in the Before Form pieces looks like:
$this->execPieceByName('ff_InitLib'); // Include BreezingForms Library
$lang = JFactory::getLanguage(); // Get Language
$lang_tag = $lang->getTag(); // Get Language Code xx-XX

$db = JFactory::getDbo(); // Get Database Object

$db->setQuery(‘SELECT lang_code FROM #__languages WHERE lang_id = 1’); 

$result = $db->loadResult(); //load the result from the query
ff_setValue(‘bfTXT’, $result); // populate the value in the form. Change ElementName to the real name of your element

Every time I try and preview the form, I get the following error:

syntax error, unexpected 'lang_code' (T_STRING), expecting ',' or ')'


I'm fairly proficient using SQL, and for the life of me I can't work out how this error is being generated.

Please Log in or Create an account to join the conversation.

Problem populating fields using SQL 11 months 2 weeks ago #237210

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hi,

Please try this :
$this->execPieceByName('ff_InitLib'); // Include BreezingForms Library
$lang = JFactory::getLanguage(); // Get Language
$lang_tag = $lang->getTag(); // Get Language Code xx-XX

$db = JFactory::getDbo(); // Get Database Object

$db->setQuery('SELECT lang_code FROM #__languages WHERE lang_id = 1'); 

$result = $db->loadResult(); //load the result from the query
ff_setValue('bfTXT', $result); // populate the value in the form. Change ElementName to the real name of your element

At the code your provided I found some odd looking quotation marks (‘) and I changed them to regular ones...

Let me know if it works now.

Regards,
mario

Please Log in or Create an account to join the conversation.

Problem populating fields using SQL 11 months 2 weeks ago #237214

  • Topic Author
  • baileynp
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 76
  • Thanks: 1
Cool

I hadn't noticed that. My editor was indeed inserting some strange single quote characters.

Thanks

Please Log in or Create an account to join the conversation.

Problem populating fields using SQL 11 months 2 weeks ago #237215

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hi,

Great !
Glad that everything is working now :)

Regards,
Mario
The following user(s) said Thank You: baileynp

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.047 seconds

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!