close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Checkbox unchecked not returning a 0 in DB

Thread began 6/28/2013 4:44 am by mrs | Last modified 6/28/2013 5:37 am by mrs | 624 views | 2 replies |

mrs

Checkbox unchecked not returning a 0 in DB

I have a couple of checkboxes on a page that work and pass a value of 1 when checked, but when unchecked, I am getting a value of NULL rather than 0. I am using the 0 for other functions across my pages, so need it to work!

I used security assist to build a log in and registration / user update / password reminder etc, but none of the menus or check boxes could have BD values tied to them during in the wizard, so I then manually tied the menus and checkboxes to the DB. The menus work fine, but the checkboxes only work when a value of 1 (checked) is passed to the DB.

I manually tied it by selecting the checkbox and in the properties panel giving a value of 1 and then clicking the Dynamic button setting the check if to <?php $row_SecurityAssisttblstudents['fld_sALLERGIES'] ?> and the value to 1.

Here's the checkbox code:
<input <?php if (!(strcmp($row_SecurityAssisttblstudents['fld_sALLERGIES'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="User_Update_group_11_Any_allergies" id="User_Update_group_11_Any_allergies" value="1" class="formCheckboxField_Standard"<?php echo $row_SecurityAssisttblstudents["fld_sALLERGIES"]; ?> tabindex="11">

And the update code:
<?php
// WA DataAssist Update
if ((isset($_POST["UserUpdate_submit"]) && $_POST["UserUpdate_submit"] != "")) // Trigger
{
$WA_connection = $conn_mrs;
$WA_table = "tbl_students";
$WA_redirectURL = "index.php?success=1";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = true;
$WA_indexField = "fld_sID";
$WA_fieldNamesStr = "fld_sNAME|fld_sPASSWORD|fld_sGENDER|fld_sHOUSENO|fld_sSTREET|fld_sDISTRICT|fld_sTOWN|fld_sCOUNTY|fld_sPOSTCODE|fld_sACTIVITY|fld_sALLERGIES|fld_sMEDICAL";
$WA_fieldValuesStr = "".((isset($_POST["User_Update_group_Full_name"]))?$_POST["User_Update_group_Full_name"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_Password"]))?$_POST["User_Update_group_Password"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_Gender"]))?$_POST["User_Update_group_Gender"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_House_No"]))?$_POST["User_Update_group_House_No"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_Street"]))?$_POST["User_Update_group_Street"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_District"]))?$_POST["User_Update_group_District"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_Town"]))?$_POST["User_Update_group_Town"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_County"]))?$_POST["User_Update_group_County"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_Postcode"]))?$_POST["User_Update_group_Postcode"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_10_Activity"]))?$_POST["User_Update_group_10_Activity"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_11_Any_allergies"]))?$_POST["User_Update_group_11_Any_allergies"]:"") ."" . $WA_AB_Split . "".((isset($_POST["User_Update_group_1_Medical_requirements"]))?$_POST["User_Update_group_1_Medical_requirements"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|none,none,NULL";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".((isset($_SESSION["SecurityAssist_fld_sID"]))?$_SESSION["SecurityAssist_fld_sID"]:"") ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode($WA_AB_Split, $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_conn_mrs;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

What am I missing?

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

In the update record behavior, set the Data Type for the allergies field to Checkbox 1,0

Sign in to reply to this post

mrs

Aha, simples... thank you Jason

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...