disturbed1 Posted April 19, 2008 Share Posted April 19, 2008 Hello I have one checkbox on my form and it is supposed to put a 1 in the database if it is checked and a 0 if it isn't checked. My problem is that whether the box is checked or unchecked only 0's are placed into the database. How can I fix this problem? The type that I am using for the checkbox is bool/tiny int. <?php $DRCVD = $_POST['DRCVD']; $OCONT = $_POST['OCONT']; $CONTENTS = $_POST['CONTENTS']; $DEADLINE = $_POST['DEADLINE']; $GIVENTO = $_POST['GIVENTO']; $STATUS = $_POST['STATUS']; $COMPLETED = $_POST['COMPLETED']; $OUTCOME = $_POST['OUTCOME']; $NOTES = $_POST['NOTES']; $con = mysql_connect("hahfhfh", "fggh", "agagg"); mysql_select_db("ahfhfshfsh", $con); $query = "INSERT INTO cases (DRCVD, OCONT, CONTENTS, DEADLINE, GIVENTO, STATUS, COMPLETED, OUTCOME, NOTES) VALUES ( '$DRCVD', '$OCONT', '$CONTENTS', '$DEADLINE', '$GIVENTO', '$STATUS', '$OUTCOME', '$NOTES',"; if (isset($COMPLETED)) $query = $query . "1 )"; else $query = $query . "0 )"; $result = mysql_query($query); ?> Link to comment https://forums.phpfreaks.com/topic/101909-checkbox-data-not-going-into-database/ Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 Your query will put the contents of $OUTCOME into the completed column Link to comment https://forums.phpfreaks.com/topic/101909-checkbox-data-not-going-into-database/#findComment-521592 Share on other sites More sharing options...
AndyB Posted April 19, 2008 Share Posted April 19, 2008 Your query will put the contents of $OUTCOME into the completed column Hint: nine fields in the query and only eight values Link to comment https://forums.phpfreaks.com/topic/101909-checkbox-data-not-going-into-database/#findComment-521601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.