Column "____" cannot be null

[left]Hello, I’m a new PHP enthusiest, trying to get my first site + database connection up and running. I’m using dreamweaver to help connect my PHP form to my database… so far to no avail. The first hurdle I’m encountering is an error message I get after I click my submit button… it is the line “Column “createEmail” cannot be null” It says this even when I am submitted it with text in the createEmail form field. Any ideas what I may be doing wrong? Thanks so much for the help![/left]
[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]

[code]

Jennifer and Michael's Wedding in Spain
    <link rel="stylesheet" href="css/bootstrap.css">
    <style> 
        body { padding-top: 105px; }
    </style>
    <link rel="stylesheet" href="css/bootstrap-responsive.css">
    <link rel="stylesheet" href="css/font-awesome.css">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet"  title="red" href="css/red.css">
    <!--[if lt IE 9]>
        <script src="js/html5-3.6-respond-1.1.0.min.js"></script>
    <![endif]-->
<link rel="shortcut icon" href="http://www.jenmike.com/favicon.ico">
</head>
<body>
    
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <i class="icon icon-reorder"></i> Menu
                </a>
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        <li><a href="index.html">Home</a></li>
                        <li><a href="story.html">Our Story</a></li>
                        <li><a href="venue.html">Venue</a></li>
                        <li><a href="activities.html">Activities</a></li>
                        <li><a href="blog.html">Blog</a></li>
                        <li><a href="registry.html">Registry</a></li>
                        <li class="active"><a href="login.php">RSVP</a></li>
					</ul>
                </div><!--/.nav-collapse -->
            </div>
        </div>
		<div class="sub-navbar">
			<div class="container">
			  <p style="color:black;"><i class="icon icon-user"></i> Hello, Guest. <a class="btn btn-login" href="rsvp.php">Login here &raquo;</a></p>
			</div>
		</div>
    </div>
    
    <div class="main">
    	<div class="container">
    		
			<h2><span>RSVP Form</span></h2>
            <div>
            <p>

Please enter you RSVP information below.

First: Provide your email address and the password you would like to use on this site. This will enable you to view wedding photos, videos, and other content after the wedding.

Second: Enter your name, whether you can attend, how many guests you expect to bring, and you're rough arrival and departure dates. This will help us schedule transportation and activities for you and your guests.

Third: Enter which activities you would be interested in. We will use this data to organize trips for the group during your time in Barcelona.

Finally: Click submit! This data will be saved in our database. If you would like to change any of the choices you made, you can revisit the site, re-enter your email and password, and make changes to this form. After submitting, check your email for a confirmation message including a reminder with your username and password.


          <div class="row">
    			<div class="span6">
                    <strong>Basic Information:</strong>
                    <br/>
                    <br/>
          <form action="<?php echo $editFormAction; ?>" method="POST" name="RSVPform" class="form-horizontal">
                        <div class="control-group">
                            <label class="control-label" for="createEmail">Email address</label>
                            <div class="controls">
                                <input class="input-xlarge" type="text" id="createEmail" placeholder="[email protected]">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="createPassword">Create a password</label>
                            <div class="controls">
                                <input class="input-xlarge" type="password" id="createPassword" placeholder="Password">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="confirmPassword">Confirm password</label>
                            <div class="controls">
                                <input class="input-xlarge" type="password" id="confirmPassword" placeholder="Password">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="createName">Your name</label>
                            <div class="controls">
                                <input class="input-xlarge" type="text" id="createName" placeholder="John Appleseed">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="createAttendance">Will You Attend?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="createAttendance" value="" id="createAttendance">
                                <div class="btn-group btn-group-vertical" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">Accept with pleasure</button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">Decline with regret </button>
                                </div>
                            </div>
                        </div>
                            
                      <div class="control-group">
                            <label class="control-label" for="GuestNumber">Guests with you?</label>
                           <div class="controls">
                                <input class="input-xlarge" type="text" id="GuestNumber" placeholder="0, 1, 2, 3...">
                           </div>
                      </div> 
                       <div class="control-group">
                            <label class="control-label" for="ArrivalDate">When do you plan to arrive in Barcelona?</label>
                           <div class="controls">
                                <input class="input-xlarge" type="text" id="ArrivalDate" placeholder="MM/DD">
                           </div>
                      </div>
                      <div class="control-group">
                            <label class="control-label" for="DepartureDate">When do you plan to depart Barcelona?</label>
                           <div class="controls">
                                <input class="input-xlarge" type="text" id="DepartureDate" placeholder="MM/DD">
                           </div>
                      </div>
                      <div class="control-group">
                            <label class="control-label" for="Comments">Any additional comments?</label>
                           <div class="controls">
                             <input class="input-xlarge" type="text" id="Comments" placeholder="Meal considerations, questions...">
                           </div>
                      </div>
                 </div>
                      <!--/span6-->
               
        		<div class="span6">
                    <strong>Are you interested in...:</strong>
                    <br/>
                    <br/>  
                        <div class="control-group">
                            <label class="control-label" for="WineTour">Going on a wine tour?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="WineTour" value="" id="WineTour">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">Yes</button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">No </button>
                                </div>
                            </div>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label" for="BarcelonaTour">Group tour of Barcelona?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="BarcelonaTour" value="" id="BarcelonaTour">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">Yes</button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">No </button>
                                </div>
                            </div>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label" for="Pamplona">Day trip to Pamplona for Bull Run?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="Pamplona" value="" id="Pamplona">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">Yes</button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">No </button>
                                </div>
                            </div>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label" for="Flamenco">Attending Flamenco dance show?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="Flamenco" value="" id="Flamenco">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">   Yes  </button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">   No  </button>
                                </div>
                            </div>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label" for="Hiking">Going hiking and kayaking?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="Hiking" value="" id="Hiking">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">   Yes  </button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">   No  </button>
                                </div>
                            </div>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label" for="Costabrava">Day trip to Costa Brava?</label>
                            <div class="controls">
                                <input class="btn-group" type="hidden" name="Costabrava" value="" id="Costabrava">
                                <div class="btn-group" data-toggle="buttons-radio">
                                <button id="btn-one" type="button" data-toggle="button" name="option" value="1" class="btn btn-secondary">   Yes  </button>
                                <button id="btn-two" type="button" data-toggle="button" name="option" value="2" class="btn btn-secondary">   No  </button>
                                </div>
                            </div>         
                        </div>            
                    </div>
                    <button type="submit" class="btn">Confirm RSVP</button>
                    <input type="hidden" name="MM_insert" value="RSVPform">
	  </div><!--/span6-->
</div><!--/row-->
            <hr> 
    	</div><!--/container-->
    </div><!--/main-->
    
    <footer>
    	<div class="container">
    		<div class="row">
    			<p>Designed by Mike and Jen - 2012</p>
    		</div>
    	</div>
    </footer>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/jquery-1.8.0.min.js"><\/script>')</script>

    <script src="js/bootstrap.min.js"></script>

    <script src="js/script.js"></script>
</body>
[/code]

The error is based on your table structure. You can either allow null values or not.

You don’t appear to be passing any ‘name’ on this input.

<input class="input-xlarge" type="text" id="createEmail" placeholder="[email protected]">

If you want to access $_POST[‘createEmail’] then you need to pass the name value e.g.

<input class="input-xlarge" type="text" name="createEmail" id="createEmail" placeholder="[email protected]">

Sponsor our Newsletter | Privacy Policy | Terms of Service