使用 PHP 表单错误将数据添加到数据库


Adding Data to DB using PHP Form ERROR

im 有一个列错误,但我似乎找不到问题。我试图将患者分类添加到名为"患者"的表中。我收到以下错误:

无法输入数据:列计数与第 1 行的值计数不匹配

谁能帮忙为什么?

PHP代码:

 <?php
     if(isset($_POST['add'])) {
        $dbhost = 'localhost';
        $dbuser = 'carl';
        $dbpass = 'password';
        $conn = mysql_connect($dbhost, $dbuser, $dbpass);
        if(! $conn ) {
           die('Could not connect: ' . mysql_error());
        }

            $PatientName = $_POST['PatientName'];
            $IDNumber = $_POST['IDNumber'];
            $Gender = $_POST['Gender'];
            $Address = $_POST['Address'];
            $LandlineTel = $_POST['LandlineTel'];
            $MobileTel = $_POST['MobileTel'];
            $DOB = $_POST['DOB'];
            $Conditions = $_POST['Conditions'];
            $NextOfKin = $_POST['NextOfKin'];
            $ClinicNo = $_POST['ClinicNo'];
            $Appointments = $_POST['Appointments'];
        $sql = "INSERT INTO Patient ". "(PatientName,IDNumber, Gender, Address, LandlineTel, MobileTel, DOB, Conditions, NextOfKin, ClientNo, Appointments) ". "VALUES('$PatientName','$IDNumber', $Gender, $Address, $LandlineTel, $MobileTel, $DOB, $Conditions, $NextOfKin, $ClinicNo, $Appointments, NOW())";
        mysql_select_db('MedicalDB');
        $retval = mysql_query( $sql, $conn );
        if(! $retval ) {
           die('Could not enter data: ' . mysql_error());
        }
        echo "Entered data successfully'n";
        mysql_close($conn);
     }else {
        ?>

网页格式代码:

<form method = "post" action = "<?php $_PHP_SELF ?>">
              <table width = "400" border = "0" cellspacing = "1" 
                 cellpadding = "2">
                 <tr>
                    <td width = "100">Employee Name</td>
                    <td><input name = "PatientName" type = "text" 
                       id = "PatientName"></td>
                 </tr>
                 <tr>
                    <td width = "100">ID Number</td>
                    <td><input name = "IDNumber" type = "text" 
                       id = "IDNumber"></td>
                 </tr>
                 <tr>
                    <td width = "100">Gender</td>
                    <td><input name = "Gender" type = "text" 
                       id = "Gender"></td>
                 </tr>
                  <tr>
                    <td width = "100">Address</td>
                    <td><input name = "Address" type = "text" 
                       id = "Address"></td>
                 </tr>
                  <tr>
                    <td width = "100">LandlineTel</td>
                    <td><input name = "LandlineTel" type = "text" 
                       id = "LandlineTel"></td>
                 </tr>
                  <tr>
                    <td width = "100">MobileTel</td>
                    <td><input name = "MobileTel" type = "text" 
                       id = "MobileTel"></td>
                 </tr>
                  <tr>
                    <td width = "100">DOB</td>
                    <td><input name = "DOB" type = "text" 
                       id = "DOB"></td>
                 </tr>
                  <tr>
                    <td width = "100">Conditions</td>
                    <td><input name = "Conditions" type = "text" 
                       id = "Conditions"></td>
                 </tr>
                  <tr>
                    <td width = "100">Next Of Kin</td>
                    <td><input name = "NextOfKin" type = "text" 
                       id = "NextOfKin"></td>
                 </tr>
                  <tr>
                    <td width = "100">Clinic Number</td>
                    <td><input name = "ClinicNo" type = "text" 
                       id = "ClinicNo"></td>
                 </tr>
                   <tr>
                    <td width = "100">Appointments</td>
                    <td><input name = "Appointments" type = "text" 
                       id = "Appointments"></td>
                 </tr>
                 <tr>
                    <td width = "100"> </td>
                    <td> </td>
                 </tr>
                 <tr>
                    <td width = "100"> </td>
                    <td>
                       <input name = "add" type = "submit" id = "add" 
                          value = "Add Employee">
                    </td>
                 </tr>
              </table>
           </form>

查询未指定尝试将NOW()的值插入到哪一列。 您有 11 列和 12 个值。