Field 'authkey' doesn't have a default value
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 15, 2017 (RSS)
By Toledoh - May 7, 2017
Hi Guys.
I'm trying to quickly update a site to capture standard emailForm.php type input and add the data to the newsletter subscribers table...
I'm using the following, but get the error: Field 'authkey' doesn't have a default value.
mysqlStrictMode( false );
$colsToValues = array(
'email' => $_REQUEST['email'],
'first_name' => $_REQUEST['fullname'],
'phone' => $_REQUEST['phone'],
'authkey' => _nlb_generateAuthKey()
);
$recordNum = mysql_insert('_nlb_subscribers', $colsToValues, true);
$subscriber = mysql_get('_nlb_subscribers', $recordNum);
Any ideas?
Tim (toledoh.com.au)
By ross - May 15, 2017
Hi Tim
Thanks for posting.
I think what's happening here is you are using a recent version of Newsletter Builder.
Version 3 and higher no longer has the function "_nlb_generateAuthKey()".
What you'll want to do is instead is something like this:
// generate auth key - example: 64a3fb69cc - over a trillian possible values (16**10)
$authkey = substr( md5(mt_rand()), 0, 12 );
$colsToValues = array('email' => $_REQUEST['email'],
'first_name' => $_REQUEST['fullname'],
'phone' => $_REQUEST['phone'],
'authkey' => $authkey
);
$recordNum = mysql_insert('_nlb_subscribers', $colsToValues, true);
$subscriber = mysql_get('_nlb_subscribers', $recordNum);
Does that make sense?
Give it a shot and let me know any questions
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/