我把这一切全部工作然后在表单中添加了7个字段,sql现在无法正常工作。错误:1136:列数与第1行的值计数不匹配。
是的,我知道这意味着什么,但我似乎无法找到不匹配的地方。 也许更多关注代码会有所帮助 - 我整夜都在看这个。形式:
<form id="registration" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend><h1>Registration</h1></legend>
<label for="entrynum">Entry Number</label>
<input type="number" pattern="\d*" name="entrynum" id="entrynum" value="" required="true" placeholder="" autofocus onchange="entry_check()" />
<label for="fname">First Name</label>
<input type="text" name="fname" id="fname" value="" required="true" placeholder="" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="lname">Last Name</label>
<input type="text" name="lname" id="lname" value="" required="true" placeholder="" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="email">eMail</label>
<input type="email" name="email" id="email" />
<label for="club">Address</label>
<input type="text" name="address" id="address" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="club">City</label>
<input type="text" name="city" id="city" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="club">State</label>
<input type="text" name="state" id="state" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="club">Zip</label>
<input type="number" pattern="\d{5}" name="zip" id="zip" value="" required="true" placeholder="" />
<label for="phone">Phone</label>
<input type="text" name="phone" id="phone" value="" placeholder="" list="" pattern="[\(]\d{3}[\)]\s\d{3}[\-]\d{4}" title='Phone Number Format: (999) 999-9999' onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" />
<label for="phone">Alt Phone</label>
<input type="text" name="altphone" id="altphone" value="" placeholder="" list="" pattern="[\(]\d{3}[\)]\s\d{3}[\-]\d{4}" title='Phone Number Format: (999) 999-9999' onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" />
<label for="phone">Fax</label>
<input type="text" name="fax" id="fax" value="" placeholder="" list="" pattern="[\(]\d{3}[\)]\s\d{3}[\-]\d{4}" title='Phone Number Format: (999) 999-9999' onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" />
<label for="club">Car Club</label>
<input type="text" name="club" id="club" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="club">Access</label>
<input type="text" name="access" id="access" list="" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="year">Year</label>
<input type="number" pattern="\d{4}" name="year" id="year" value="" required="true" placeholder="" />
<label for="make">Make</label>
<input type="text" name="make" id="make" required="true" list="makes" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="model">Model</label>
<input type="text" name="model" id="model" required="true" list="models" style="text-transform:capitalize" onkeyup="javascript:this.value=this.value.charAt(0).toUpperCase() + this.value.substr(1);" />
<label for="plates">Plates</label>
<input type="text" name="plates" id="plates" list="" style="text-transform:uppercase" onkeyup="javascript:this.value=this.value.toUpperCase();" />
<fieldset>
<legend><h2>Registration Notes</h2></legend>
<textarea rows="5" cols="80%" name="regnotes" id="regnotes"></textarea>
</fieldset><br><br>
<input type="submit" name="reg-submit" id="reg-submit" value="Submit" />
</fieldset> <!-- Registration Form-->
<?php include("includes/datalist.php"); ?>
</form>
process.php
<?php
include("includes/connect.php");
error_reporting(E_ALL);
ini_set('display_errors', 'On');
date_default_timezone_set('US/Central');
session_start();
$datenow = date("y-m-d");
$timenow = date("h:i:sa");
$error = FALSE;
if (!isset($entrynum)) {
$error = TRUE;
}
if (isset($_POST['class'])) {
$class = $_POST['class'];
$class = trim($class);
$class = strip_tags($class);
}
// registration
if (!empty($_POST['reg-submit'])) {
$entrynum = $_POST['entrynum'];
$_SESSION['entrynum'] = $entrynum;
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$altphone = $_POST['altphone'];
$fax = $_POST['fax'];
$club = $_POST['club'];
$access = $_POST['access'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$plates = $_POST['plates'];
$regnotes = $_POST['regnotes'];
if (isset($regnotes)) {
$regnotes = trim($regnotes);
$regnotes = strip_tags($regnotes);
}
$sql = "INSERT INTO HeatWaveData (`entrynum`, `fname`, `lname`, `email`, `address`, `city`, `state`, `zip`, `phone`, `altphone`, `fax`, `club`, `access`, `year`, `make`, `model`, `plates`, `regnotes`, `dated`, `timed`)
VALUES ('$entrynum', '$fname', '$lname', '$email', '$address', '$city', '$state', '$zip', '$phone', '$altphone', '$fax', '$club', '$access' '$year', '$make', '$model', '$plates', '$regnotes', '$datenow', '$timenow')
ON DUPLICATE KEY
UPDATE entrynum='$entrynum', fname='$fname', lname='$lname', email='$email', address='$address', city='$city', state='$state', zip='$zip', phone='$phone', altphone='$altphone', fax='$fax', club='$club', access='$access', year='$year', make='$make', model='$model', plates='$plates', regnotes='$regnotes', dated='$datenow', timed='$timenow'";
if (!$db->query($sql)) { die("Error: {$db->errno} : {$db->error}"); }
header("Refresh: 3; url=upload.php");
}
?>
答案 0 :(得分:2)
您的值行中缺少逗号,$access
和$year
之间
VALUES ('$entrynum', '$fname', '$lname', '$email', '$address', '$city',
'$state', '$zip', '$phone', '$altphone', '$fax', '$club', '$access', <--
'$year', '$make', '$model', '$plates', '$regnotes', '$datenow', '$timenow')