Membership Signup Form Syntax question
7 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 31, 2011 (RSS)
By gkornbluth - August 29, 2011 - edited: August 30, 2011
It's time to feel silly again...
But, I could use some guidance regarding the correct syntax to use in this situation.
In a membership signup form, I want to pull the number of records allowed (maxRecords) from a text field called “entry_level_records”, in a single record editor called “subscriber_level_values”.
At the top of the page I loaded the records with:
list($subscriber_level_valuesRecords, $subscriber_level_valuesMetaData) = getRecords(array(
'tableName' => 'subscriber_level_values',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$subscriber_level_valuesRecord = @$subscriber_level_valuesRecords[0]; // get first record
I defined a variable as:
<?php $records_allowed = $subscriber_level_valuesRecord['entry_level_records']; ?>
I can print out the correct value of the $records_allowed variable with:
<?php echo $records_allowed ; ?>
But when I insert the variable in the "create access list" code as below, I get a 0 as the maxRecords value.
($userNum, 'master_subscription_pages', '6', '(echo $records_allowed)', '1234567890'),
I've also tried
'echo $records_allowed'
'echo [$records_allowed]'
'(echo [$records_allowed])'
and they also rendered 0 for the maxRecords value.
Any suggestions?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Membership Signup Form Syntax question
By robin - August 30, 2011
Could you post the full SQL you're using to insert into the accesslist? I think that would help a lot to track the problem down.
Thanks,
Robin
Programmer
interactivetools.com
Re: [robin] Membership Signup Form Syntax question
By gkornbluth - August 30, 2011 - edited: August 30, 2011
I think I found the answer.
It appears the code should be
'$records_allowed'
without the "echo".Oh well.
Learning comes slow sometimes.
Thanks,
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Membership Signup Form Syntax question
By robin - August 30, 2011
Glad you got the problem fixed. Problems within a string can be hard to track down!
Thanks,
Robin
Programmer
interactivetools.com
Re: [robin] Membership Signup Form Syntax question
By gkornbluth - August 30, 2011 - edited: August 31, 2011
The code works with numerical values as the value pulled from the subscriber_level_values text field, but doesn’t work when I try to insert the value NULL.
I’ve attached the Viewer code in the hope that it's an easy solution.
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Membership Signup Form Syntax question
By robin - August 31, 2011
I think your problem might be database related. If you try to insert a NULL into a integer field in MySQL you can't use single quotes because then it's a string 'NULL' instead of a real NULL.
so
$records_allowed
instead of '$records_allowed'
Hope that helps,
Robin
Programmer
interactivetools.com
Re: [robin] Membership Signup Form Syntax question
Thanks Robin
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php