Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Membership Signup Form Syntax question

 

 


gkornbluth
Veteran

Aug 29, 2011, 10:08 AM

Post #1 of 7 (1204 views)
Shortcut
Membership Signup Form Syntax question Can't Post

Hi All,

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:

Code
 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:

Code
<?php $records_allowed = $subscriber_level_valuesRecord['entry_level_records']; ?>

I can print out the correct value of the $records_allowed variable with:

Code
  <?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.

Code
($userNum, 'master_subscription_pages',        '6',          '(echo $records_allowed)',          '1234567890'),

I've also tried

Code
'echo $records_allowed' 
'echo [$records_allowed]'
'(echo [$records_allowed])'

and they also rendered 0 for the maxRecords value.

Any suggestions?

Thanks,

Jerry Kornbluth

(This post was edited by gkornbluth on Aug 30, 2011, 6:27 AM)


robin
User / Moderator


Aug 30, 2011, 8:49 AM

Post #2 of 7 (1094 views)
Shortcut
Re: [gkornbluth] Membership Signup Form Syntax question [In reply to] Can't Post

Hey Jerry,

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


gkornbluth
Veteran

Aug 30, 2011, 9:16 AM

Post #3 of 7 (1092 views)
Shortcut
Re: [robin] Membership Signup Form Syntax question [In reply to] Can't Post

Robin,

I think I found the answer.

It appears the code should be

Code
'$records_allowed'

without the "echo".

Oh well.

Learning comes slow sometimes.

Thanks,

Jerry

(This post was edited by gkornbluth on Aug 30, 2011, 1:05 PM)


robin
User / Moderator


Aug 30, 2011, 3:50 PM

Post #4 of 7 (1064 views)
Shortcut
Re: [gkornbluth] Membership Signup Form Syntax question [In reply to] Can't Post

Hey Jerry,

Glad you got the problem fixed. Problems within a string can be hard to track down!

Thanks,
Robin


gkornbluth
Veteran

Aug 30, 2011, 6:14 PM

Post #5 of 7 (1052 views)
Shortcut
Re: [robin] Membership Signup Form Syntax question [In reply to] Can't Post

OK, I spoke too soon.

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

(This post was edited by gkornbluth on Aug 31, 2011, 10:34 AM)
Attachments: platinumlevelsignup.php (26.8 KB)


robin
User / Moderator


Aug 31, 2011, 10:35 AM

Post #6 of 7 (1004 views)
Shortcut
Re: [gkornbluth] Membership Signup Form Syntax question [In reply to] Can't Post

Hey Jerry,

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


Code
$records_allowed

instead of

Code
'$records_allowed'


Hope that helps,
Robin


gkornbluth
Veteran

Aug 31, 2011, 10:44 AM

Post #7 of 7 (1002 views)
Shortcut
Re: [robin] Membership Signup Form Syntax question [In reply to] Can't Post

You're SOOOO smart.

Thanks Robin
The first CMS Builder reference book is now available on-line!
http://www.thecmsbcookbook.com