MySQL error: Column count doesn't match value count at row 1

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cliffordpg
Forum Newbie
Posts: 1
Joined: Fri Mar 26, 2010 10:41 am

MySQL error: Column count doesn't match value count at row 1

Post by cliffordpg »

I'm facing the following error while posting a form to mysql database (trying to get this right before i complete the form field validations. any suggestions?

Custom INFO: SQL Query fail: insert into eval values (NULL, ' ', 'abc', '1234', 'esdfa', 'sdfad', '02', 'February', '1974', '', '000111444', 'me@you.com', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '1' )
MySQL error: Column count doesn't match value count at row 1
MySQL error number: 1136
Date: Friday, March 26, 2010 at 3:44:50 PM
Script: /rbmdav.php
Referer: http://localhost/rbmdav.php

form code as below

Code: Select all

 
                if (isset($_POST['send_enquiry_x'])) {
 
                    $form = $_POST['form'];
 
                    if (empty($form['title'])) {
                        $mark['title']  = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['rbm_casep1'])) {
                        $mark['rbm_casep1']     = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['rbm_casep2'])) {
                        $mark['rbm_casep2']     = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['fname'])) {
                        $mark['fname']  = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['sname'])) {
                        $mark['sname']  = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['dob'])) {
                        $mark['dob']    = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['mob'])) {
                        $mark['mob']    = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['yob'])) {
                        $mark['yob']    = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['tel'])) {
                        $mark['tel'] = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['email'])) {
                        $mark['email']  = 1;
                        $empty                  = 1;
                    }
                    if (empty($form['check_loa'])) {
                        $mark['title']  = 1;
                        $empty                  = 1;
                    }
                    if($form['register'] == 1) {
                        $register = " checked";
                    }
 
                    if ($empty == 1) {
                        $output->msg .= "Please check your entries or complete all marked fields (<span class='red'>*</span>).<br />";
                        $display_form = 1;
                    }
 
                    $auth = new authorise;
                    $auth->check_email($form['email']);
                    if ($auth->email_chk1 != 1 || $auth->email_chk2 != 1) {
                        $output->msg .= "Invalid email address.<br />";
                        $mark['email']= 1;
                    }
 
                    if ($output->msg == "") {
 
                        $sendmail = new sendmail;
                        $sendmail->send_enquiry($form);
 
                        if ($sendmail->mail_sent = "true") {
 
                            if($form['register'] == 0) {
 
                                $sql = "insert into eval values (NULL, " .
                                "'".addslashes($form['title'])."', " .
                                "'".addslashes($form['rbm_casep1'])."', " .
                                "'".addslashes($form['rbm_casep2'])."', " .
                                "'".addslashes($form['fname'])."', " .
                                "'".addslashes($form['sname'])."', " .
                                "'".addslashes($form['dob'])."', " .
                                "'".addslashes($form['mob'])."', " .
                                "'".addslashes($form['yob'])."', " .
                                "'".addslashes($form['address'])."', " .
                                "'".addslashes($form['tel'])."', " .
                                "'".addslashes($form['email'])."', " .
                                "'".addslashes($form['pen_provider'])."', " .
                                "'".addslashes($form['ppolicy'])."', " .
                                "'".addslashes($form['ppolicy1'])."', " .
                                "'".addslashes($form['ppolicy2'])."', " .
                                "'".addslashes($form['ppolicy3'])."', " .
                                "'".addslashes($form['ppolicy4'])."', " .
                                "'".addslashes($form['ppolicy5'])."', " .
                                "'".addslashes($form['ins_provider'])."', " .
                                "'".addslashes($form['ipolicy'])."', " .
                                "'".addslashes($form['ipolicy1'])."', " .
                                "'".addslashes($form['ipolicy2'])."', " .
                                "'".addslashes($form['ipolicy3'])."', " .
                                "'".addslashes($form['ipolicy4'])."', " .
                                "'".addslashes($form['ipolicy5'])."', " .
                                "'".addslashes($form['add_info'])."', " .
                                "'".addslashes($form['check_loa'])."' )";
                                $result = $db->query($sql);
                            }
 
                            $output->msg .= "Thank you for registering your details with ".COMPANY_NAME.".  We will be in touch shortly.";
                            $display_form = 0;
 
 
                        } else {
                            $output->msg .= "Sorry, there has been an error processing your request.  Please try again later.";
                            $display_form = 1;
 
                        }
                    }
 
                }
 
                if ($output->msg != "") {
                    echo $output->display_msg();
                }
 

Code: Select all

 
                if ($display_form == 1) {
                    ?>
                    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
                    <fieldset>
                    <div class="form_style">
                    <table class="form_table" width="100%">
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> Title:</th>
                    <td>
                    <select name="form[title]"<?php if ($mark['title'] == 1) { echo " class=\"required\""; } ?>>
                    <option value=" "<?php if ($form['title'] == " ") { echo " selected=\"selected\""; }?>> </option>
                    <option value=" "<?php if ($form['title'] == "Dr") { echo " selected=\"selected\""; }?>>Dr</option>
                    <option value="Mr"<?php if ($form['title'] == "Mr") { echo " selected=\"selected\""; } ?>>Mr</option>
                    <option value="Mrs"<?php if ($form['title'] == "Mrs") { echo " selected=\"selected\""; } ?>>Mrs</option>
                    <option value="Miss"<?php if ($form['title'] == "Miss") { echo " selected=\"selected\""; } ?>>Miss</option>
                    <option value="Ms"<?php if ($form['title'] == "Ms") { echo " selected=\"selected\""; } ?>>Ms</option>
                    </select>
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> RBM Davies Case Number (e.g. ABC-1234):</th>
                    <td><input type="text" maxlength="3" style="width: 40px;" name="form[rbm_casep1]" value="<?php echo $form['rbm_casep1'];?>" class="<?php if ($mark['rbm_casep1'] == 1) { echo "required"; } else { echo "textinput"; } ?>" /> - <input type="text" maxlength="4" style="width: 40px;" name="form[rbm_casep2]" value="<?php echo $form['rbm_casep2'];?>" class="<?php if ($mark['rbm_casep2'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> First Name:</th>
                    <td><input type="text" style="width: 280px;" name="form[fname]" value="<?php echo $form['fname'];?>" class="<?php if ($mark['fname'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> Last Name:</th>
                    <td><input type="text" style="width: 280px;" name="form[sname]" value="<?php echo $form['sname'];?>" class="<?php if ($mark['sname'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> Date of Birth:</th>
                    <td>
                    <select overflow-y="scroll" name="form[dob]"<?php if ($mark['dob'] == 1) { echo " class=\"required\""; } ?>>
                    <option value=" "<?php if ($form['dob'] == " ") { echo " selected=\"selected\""; }?>> </option>
                    <option value=" "<?php if ($form['dob'] == "01") { echo " selected=\"selected\""; }?>>01</option>
                    <option value="02"<?php if ($form['dob'] == "02") { echo " selected=\"selected\""; } ?>>02</option>
                    <option value="03"<?php if ($form['dob'] == "03") { echo " selected=\"selected\""; } ?>>03</option>
                    <option value="04"<?php if ($form['dob'] == "04") { echo " selected=\"selected\""; } ?>>04</option>
                    <option value="05"<?php if ($form['dob'] == "05") { echo " selected=\"selected\""; } ?>>05</option>
                    <option value="06"<?php if ($form['dob'] == "06") { echo " selected=\"selected\""; } ?>>06</option>
                    <option value="07"<?php if ($form['dob'] == "07") { echo " selected=\"selected\""; } ?>>07</option>
                    <option value="08"<?php if ($form['dob'] == "08") { echo " selected=\"selected\""; } ?>>08</option>
                    <option value="09"<?php if ($form['dob'] == "09") { echo " selected=\"selected\""; } ?>>09</option>
                    <option value="10"<?php if ($form['dob'] == "10") { echo " selected=\"selected\""; } ?>>10</option>
                    <option value="11"<?php if ($form['dob'] == "11") { echo " selected=\"selected\""; } ?>>11</option>
                    <option value="12"<?php if ($form['dob'] == "12") { echo " selected=\"selected\""; } ?>>12</option>
                    <option value="13"<?php if ($form['dob'] == "13") { echo " selected=\"selected\""; } ?>>13</option>
                    <option value="14"<?php if ($form['dob'] == "14") { echo " selected=\"selected\""; } ?>>14</option>
                    <option value="15"<?php if ($form['dob'] == "15") { echo " selected=\"selected\""; } ?>>15</option>
                    <option value="16"<?php if ($form['dob'] == "16") { echo " selected=\"selected\""; } ?>>16</option>
                    <option value="17"<?php if ($form['dob'] == "17") { echo " selected=\"selected\""; } ?>>17</option>
                    <option value="18"<?php if ($form['dob'] == "18") { echo " selected=\"selected\""; } ?>>18</option>
                    <option value="19"<?php if ($form['dob'] == "19") { echo " selected=\"selected\""; } ?>>19</option>
                    <option value="20"<?php if ($form['dob'] == "20") { echo " selected=\"selected\""; } ?>>20</option>
                    <option value="21"<?php if ($form['dob'] == "21") { echo " selected=\"selected\""; } ?>>21</option>
                    <option value="22"<?php if ($form['dob'] == "22") { echo " selected=\"selected\""; } ?>>22</option>
                    <option value="23"<?php if ($form['dob'] == "23") { echo " selected=\"selected\""; } ?>>23</option>
                    <option value="24"<?php if ($form['dob'] == "24") { echo " selected=\"selected\""; } ?>>24</option>
                    <option value="25"<?php if ($form['dob'] == "25") { echo " selected=\"selected\""; } ?>>25</option>
                    <option value="26"<?php if ($form['dob'] == "26") { echo " selected=\"selected\""; } ?>>26</option>
                    <option value="27"<?php if ($form['dob'] == "27") { echo " selected=\"selected\""; } ?>>27</option>
                    <option value="28"<?php if ($form['dob'] == "28") { echo " selected=\"selected\""; } ?>>28</option>
                    <option value="29"<?php if ($form['dob'] == "29") { echo " selected=\"selected\""; } ?>>29</option>
                    <option value="30"<?php if ($form['dob'] == "30") { echo " selected=\"selected\""; } ?>>30</option>
                    <option value="31"<?php if ($form['dob'] == "31") { echo " selected=\"selected\""; } ?>>31</option>
                    </select> <b>/</b>
                    <select overflow-y="scroll" name="form[mob]"<?php if ($mark['mob'] == 1) { echo " class=\"required\""; } ?>>
                    <option value=" "<?php if ($form['mob'] == " ") { echo " selected=\"selected\""; }?>> </option>
                    <option value="January"<?php if ($form['mob'] == "January") { echo " selected=\"selected\""; }?>>January</option>
                    <option value="February"<?php if ($form['mob'] == "February") { echo " selected=\"selected\""; } ?>>February</option>
                    <option value="March"<?php if ($form['mob'] == "March") { echo " selected=\"selected\""; } ?>>March</option>
                    <option value="April"<?php if ($form['mob'] == "April") { echo " selected=\"selected\""; } ?>>April</option>
                    <option value="May"<?php if ($form['mob'] == "May") { echo " selected=\"selected\""; } ?>>May</option>
                    <option value="June"<?php if ($form['mob'] == "June") { echo " selected=\"selected\""; } ?>>June</option>
                    <option value="July"<?php if ($form['mob'] == "July") { echo " selected=\"selected\""; } ?>>July</option>
                    <option value="August"<?php if ($form['mob'] == "August") { echo " selected=\"selected\""; } ?>>August</option>
                    <option value="September"<?php if ($form['mob'] == "September") { echo " selected=\"selected\""; } ?>>September</option>
                    <option value="October"<?php if ($form['mob'] == "October") { echo " selected=\"selected\""; } ?>>October</option>
                    <option value="November"<?php if ($form['mob'] == "November") { echo " selected=\"selected\""; } ?>>November</option>
                    <option value="December"<?php if ($form['mob'] == "December") { echo " selected=\"selected\""; } ?>>December</option>
                    </select> <b>/</b>
                    <input type="text" maxlength="4" style="width: 40px;" name="form[yob]" value="<?php echo $form['yob'];?>" class="<?php if ($mark['yob'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px">Address:</th>
                    <td><input type="text" style="width: 280px; height:40px" name="form[address]" value="<?php echo $form['address'];?>" class="textinput" /></td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> Telephone Number:</th>
                    <td><input type="text" style="width: 280px;" name="form[tel]" value="<?php echo $form['tel'];?>" class="<?php if ($mark['tel'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px"><span class='red'>*</span> Email:</th>
                    <td><input type="text" style="width: 280px;" name="form[email]" value="<?php echo $form['email'];?>" class="<?php if ($mark['email'] == 1) { echo "required"; } else { echo "textinput"; } ?>" />
                    </td>
                    </tr>
 
                    <td colspan="2"><hr /></td>
 
                    <tr>
                    <th style="width: 300px">Pension Provider:</th>
                    <td><input type="text" style="width: 280px;" name="form[pen_provider]" value="<?php echo $form['pen_provider'];?>" class="textinput" /></td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px">Main Pension Policy Number:</th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy]" value="<?php echo $form['ppolicy'];?>" class="textinput" /></td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px">Additional Pension Policy Numbers:</th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy1]" value="<?php echo $form['ppolicy1'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy2]" value="<?php echo $form['ppolicy2'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy3]" value="<?php echo $form['ppolicy3'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy4]" value="<?php echo $form['ppolicy4'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ppolicy5]" value="<?php echo $form['ppolicy5'];?>" class="textinput" /></td><br />
                    </tr>
 
                    <td colspan="2"><hr /></td>
 
                    <tr>
                    <th style="width: 300px">Insurance Provider:</th>
                    <td><input type="text" style="width: 280px;" name="form[ins_provider]" value="<?php echo $form['ins_provider'];?>" class="textinput" /></td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px">Main Insurance Policy Number:</th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy]" value="<?php echo $form['ipolicy'];?>" class="textinput" /></td>
                    </tr>
 
                    <tr>
                    <th style="width: 300px">Additional Insurance Policy Numbers:</th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy1]" value="<?php echo $form['ipolicy1'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy2]" value="<?php echo $form['ipolicy2'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy3]" value="<?php echo $form['ipolicy3'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy4]" value="<?php echo $form['ipolicy4'];?>" class="textinput" /></td><br />
                    </tr><tr>
                    <th style="width: 300px;"> </th>
                    <td><input type="text" style="width: 280px;" name="form[ipolicy5]" value="<?php echo $form['ipolicy5'];?>" class="textinput" /></td><br />
                    </tr>
 
                    <td colspan="2"><hr /></td>
 
                    <tr>
                    <th style="width: 233px">Additional Information <span class='red'>(Optional)</span>:</th>
                    <td><input type="text" style="width: 300px; height: 40px;" name="form[add_info]" value="<?php echo $form['add_info'];?>" class="textinput" /><td>
                    </tr>
 
                    <td colspan="2"><hr /></td>
 
                    <tr><td colspan="2">
                    <strong style="text-decoration: underline">LETTER OF AUTHORITY</strong><p><span class='red'><br />I hereby authorise Wilcocks & Associates Ltd to be nominated as our servicing agent and Independent Financial Adviser. We authorise full status and information to be provided to Wilcocks & Associates Ltd on request. Please transfer all policies to their agency under the detail of; <br />Wilcocks & Associates Ltd, <br />The Plaza, <br />St Pauls Square, <br />100 Old Hall Street, <br />Liverpool, <br />L3 9QJ. <br />Company FSA number 501064. <br />Please implement immediately with effect from the date of this letter and this authority should remain in force until I notify you otherwise.</span></tr>
 
                    <tr class="style1">
                    <td colspan="2"><span class='red'>By ticking this box, I hereby confirm giving Wilcocks & Associates Ltd the authority to take action on my behalf on the afore mentioned policies. </span>
                    <input name="form[check_loa]" type="checkbox" value="1"<?php echo $form;?> class="style6" /></input>
                    </td>
                    <td>
                    </td>
                    </tr>
 
                    <tr>
                    <th style="width: 233px"></th>
                    <td><input name="send_enquiry" type="image" class="formbutton" title="Send Enquiry" value="1" src="images/button_send.gif" alt="Send Enquiry" /></td>
                    </tr>
                    </table>
                    </div>
                    <div class="form_style_bottom"></div>
                    <input type="hidden" name="form[article]" value="<?php echo $form['article'];?>" />
                    </fieldset>
                    </form>
                <?php
Last edited by Benjamin on Fri Mar 26, 2010 7:41 pm, edited 2 times in total.
Reason: Added [code=php] tags.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: MySQL error: Column count doesn't match value count at row 1

Post by mikosiko »

Code: Select all

 
MySQL error: [color=#FF0000]Column count doesn't match value count [/color]at row 1 
MySQL error number: 1136
 
seems very clear to me....

check the content of your $sql variable
Post Reply