Radio button input not working

Hello, I’m trying to get a simple twitter-bootstrap style radio button group to hand off “1” or “0” to my database via PHP. For some reason, it is not working, as the error I get on submit is “Column ‘Attendance’ cannot be null”. I’ve tried several iterations of just using as well as the way I use below… none seem to work. Is there a better way to accomplish this? Thanks so much!!!

Here is the PHP code at the top… mostly Dreamweaver produced but the “Attendance” variable is there
[php]<?php require_once('Connections/WeddingDB.php'); ?>

<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "RSVPform")) { $insertSQL = sprintf("INSERT INTO Main_User_Database (createEmail, createPassword, createName, Attendance, GuestNumber, ArrivalDate, DepartureDate, Comments, WineTour, BarcelonaTour, Pamplona, Flamenco, Hiking, Costabrava) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['createEmail'], "text"), GetSQLValueString($_POST['createPassword'], "text"), GetSQLValueString($_POST['createName'], "text"), GetSQLValueString($_POST['Attendance'], "int"), GetSQLValueString($_POST['GuestNumber'], "int"), GetSQLValueString($_POST['ArrivalDate'], "text"), GetSQLValueString($_POST['DepartureDate'], "text"), GetSQLValueString($_POST['Comments'], "text"), GetSQLValueString($_POST['WineTour'], "int"), GetSQLValueString($_POST['BarcelonaTour'], "int"), GetSQLValueString($_POST['Pamplona'], "int"), GetSQLValueString($_POST['Flamenco'], "int"), GetSQLValueString($_POST['Hiking'], "int"), GetSQLValueString($_POST['Costabrava'], "int")); mysql_select_db($database_WeddingDB, $WeddingDB); $Result1 = mysql_query($insertSQL, $WeddingDB) or die(mysql_error()); } ?>[/php]

and here is one attempt at getting the button radio group to work…

<div class="control-group"> <label class="control-label" for="Attendance">Will you attend?</label> <div class="controls"> <input class="btn-group" type="hidden" name="Attendance" value="" id="Attendance"> <div class="btn-group" data-toggle="buttons-radio"> <button id="btn-one" type="button" data-toggle="button" name="Attendance" value="1" class="btn btn-secondary">Yes</button> <button id="btn-two" type="button" data-toggle="button" name="Attendance" value="2" class="btn btn-secondary">No </button> </div> </div> </div>

If thats happening during an insert query, then check your database structure, make sure you don’t have NULLs setup in there.

Sponsor our Newsletter | Privacy Policy | Terms of Service