2016-08-24 65 views
-1

我有這個所有的工作,然後添加7個領域的形式和SQL現在不工作。錯誤:1136:列計數與第1行的值計數不匹配。錯誤: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"); 
} 
?> 

回答

2

你錯過了你的價值觀一致逗號,$access$year

VALUES ('$entrynum', '$fname', '$lname', '$email', '$address', '$city', 
    '$state', '$zip', '$phone', '$altphone', '$fax', '$club', '$access', <-- 
    '$year', '$make', '$model', '$plates', '$regnotes', '$datenow', '$timenow') 
+0

觀察母親之間) – prograshid

+0

這只是愚蠢的!我看了幾個小時。我甚至做了一個副本,並在文本編輯器中運行它,並比較每個項目等等......從來沒有見過! –

+0

@DanielYantis我sugget使用IDE,如果它來到Php也許Php Storm會幫助你很多! –

相關問題