473,659 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Column count doesn't match value count at row 1

17 New Member
this code is producing the message BUT it is entering the data. What should i do?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (!$_POST) {
  3.     //haven't seen the form, so show it
  4.     $display_block = "
  5.     <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">
  6.     <p><strong>First/Last Names:</strong><br/>
  7.     <input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"75\">
  8.     <input type=\"text\" name=\"l_name\" size=\"30\" maxlength=\"75\"></p>
  9.  
  10.     <p><strong>Address:</strong><br/>
  11.     <input type=\"text\" name=\"address\" size=\"30\"></p>
  12.  
  13.     <p><strong>City/State/Zip:</strong><br/>
  14.     <input type=\"text\" name=\"city\" size=\"30\" maxlength=\"50\">
  15.     <input type=\"text\" name=\"state\" size=\"5\" maxlength=\"2\">
  16.     <input type=\"text\" name=\"zipcode\" size=\"10\" maxlength=\"10\"></p>
  17.  
  18.     <p><strong>Address Type:</strong><br/>
  19.     <input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
  20.     <input type=\"radio\" name=\"add_type\" value=\"work\"> work
  21.     <input type=\"radio\" name=\"add_type\" value=\"other\"> other</p>
  22.  
  23.     <p><strong>Telephone Number:</strong><br/>
  24.     <input type=\"text\" name=\"tel_number\" size=\"30\" maxlength=\"25\">
  25.     <input type=\"radio\" name=\"tel_type\" value=\"home\" checked> home
  26.     <input type=\"radio\" name=\"tel_type\" value=\"work\"> work
  27.     <input type=\"radio\" name=\"tel_type\" value=\"other\"> other</p>
  28.  
  29.     <p><strong>Fax Number:</strong><br/>
  30.     <input type=\"text\" name=\"fax_number\" size=\"30\" maxlength=\"25\">
  31.     <input type=\"radio\" name=\"fax_type\" value=\"home\" checked> home
  32.     <input type=\"radio\" name=\"fax_type\" value=\"work\"> work
  33.     <input type=\"radio\" name=\"fax_type\" value=\"other\"> other</p>
  34.  
  35.     <p><strong>Email Address:</strong><br/>
  36.     <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"150\">
  37.     <input type=\"radio\" name=\"email_type\" value=\"home\" checked> home
  38.     <input type=\"radio\" name=\"email_type\" value=\"work\"> work
  39.     <input type=\"radio\" name=\"email_type\" value=\"other\"> other</p>
  40.  
  41.     <p><strong>Personal Note:</strong><br/>
  42.     <textarea name=\"note\" cols=\"35\" rows=\"3\" wrap=\"virtual\"></textarea></p>
  43.  
  44.     <p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p>
  45.     </form>";
  46.  
  47. } else if ($_POST) {
  48.     //time to add to tables, so check for required fields
  49.     if (($_POST["f_name"] == "") || ($_POST["l_name"] == "")) {
  50.         header("Location: addentry.php");
  51.         exit;
  52.     }
  53.  
  54.     //connect to database
  55.     $mysqli = mysqli_connect("localhost", "web86-geothermal", "pw002f1945", "web86-geothermal");
  56.  
  57.     //add to master_name table
  58.     $add_master_sql = "INSERT INTO tbl_master_name (master_id, date_added, date_modified, f_name, l_name)
  59.                        VALUES ('', now(), now(), '".$_POST["f_name"]."', '".$_POST["l_name"]."')";
  60.     $add_master_res = mysqli_query($mysqli, $add_master_sql) or die(mysqli_error($mysqli));
  61.  
  62.     //get master_id for use with other tables
  63.     $master_id = mysqli_insert_id($mysqli);
  64.  
  65.     if (($_POST["address"]) || ($_POST["city"]) || ($_POST["state"]) || ($_POST["zipcode"])) {
  66.         //something relevant, so add to address table
  67.         $add_address_sql = "INSERT INTO tbl_address (master_id, date_added, date_modified,
  68.                             address1, address2, city, state, zipcode, type)  VALUES ('".$master_id."',
  69.                             now(), now(), '".$_POST["address"]."', '".$_POST["city"]."',
  70.                             '".$_POST["state"]."' , '".$_POST["zipcode"]."' , '".$_POST["add_type"]."')";
  71.         $add_address_res = mysqli_query($mysqli, $add_address_sql) or die(mysqli_error($mysqli));
  72.     }
  73.  
  74.     if ($_POST["tel_number"]) {
  75.         //something relevant, so add to telephone table
  76.         $add_tel_sql = "INSERT INTO tbl_telephone (master_id, date_added, date_modified,
  77.                         tel_number, type)  VALUES ('".$master_id."', now(), now(),
  78.                         '".$_POST["tel_number"]."', '".$_POST["tel_type"]."')";
  79.         $add_tel_res = mysqli_query($mysqli, $add_tel_sql) or die(mysqli_error($mysqli));
  80.     }
  81.  
  82.     if ($_POST["fax_number"]) {
  83.         //something relevant, so add to fax table
  84.         $add_fax_sql = "INSERT INTO tbl_fax (master_id, date_added, date_modified,
  85.                         fax_number, type)  VALUES ('".$master_id."', now(), now(),
  86.                         '".$_POST["fax_number"]."', '".$_POST["fax_type"]."')";
  87.         $add_fax_res = mysqli_query($mysqli, $add_fax_sql) or die(mysqli_error($mysqli));
  88.     }
  89.  
  90.     if ($_POST["email"]) {
  91.         //something relevant, so add to email table
  92.         $add_email_sql = "INSERT INTO tbl_email (master_id, date_added, date_modified,
  93.                           email, type)  VALUES ('".$master_id."', now(), now(),
  94.                           '".$_POST["email"]."', '".$_POST["email_type"]."')";
  95.         $add_email_res = mysqli_query($mysqli, $add_email_sql) or die(mysqli_error($mysqli));
  96.     }
  97.  
  98.     if ($_POST["note"]) {
  99.         //something relevant, so add to notes table
  100.         $add_notes_sql = "INSERT INTO tbl_personal_notes (master_id, date_added, date_modified,
  101.                           note)  VALUES ('".$master_id."', now(), now(), '".$_POST["note"]."')";
  102.         $add_notes_res = mysqli_query($mysqli, $add_notes_sql) or die(mysqli_error($mysqli));
  103.     }
  104.     mysqli_close($mysqli);
  105.     $display_block = "<p>Your entry has been added.  Would you like to <a href=\"addentry.php\">add another</a>?</p>";
  106. }
  107. ?>
  108. <html>
  109. <head>
  110. <title>Add an Entry</title>
  111. </head>
  112. <body>
  113. <h1>Add an Entry</h1>
  114. <?php echo $display_block; ?>
  115. </body>
  116. </html> 
Feb 11 '08 #1
3 5540
harshmaul
490 Recognized Expert Contributor
Hi,
when your inserting address it looks like you missed out a value...

remember the insert syntax is....

Expand|Select|Wrap|Line Numbers
  1. insert into tblName (column1, column2) values ("column1","column2")
you've got something like this...

Expand|Select|Wrap|Line Numbers
  1. insert into tblName (column1, column2) values ("column1")
Where you've missed one of the columns.

let me know how you get on.
Feb 11 '08 #2
whitey
17 New Member
aha, found it.

So the message actually means that your mysql column count doesnt match the number of values it has to insert into db
Feb 11 '08 #3
harshmaul
490 Recognized Expert Contributor
yea, it could be insert, or update, i think even select if you make up the name for a column ;)

glad you solved it :)
Feb 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
10767
by: Aaron C | last post by:
Hi, I'm trying to do an insert with the following statement: INSERT INTO user VALUES ( 'ag@ag.com','ag','Aaron','Chandler','','','La Mirada','CA',90638,714,'',''); and I'm getting the error message "Column count doesn't match value count at row 1".
6
10614
by: M.Kamermans | last post by:
I have an XSLT script that has to operate on some particularly nasty XML to turn it into a SQL databse, but 'entries' in the XML aren't actually unique, so their unique identifier is useless. I need to somehow create crosslinked tables using the XSLT, but can only do this by maintaining a counter for each line I write. Is there a way to create a proxy 'increment' function that lets me maintain a counter variable? - Mike Kamermans
1
4043
by: Dmitry V. Markin | last post by:
Good day! Here is my problem: I need to have a radiobutton column in my DataGrid for a representation of a bool column, where only row can be checked at one time(only one value in bool column can be true). So I've created a class inheriting from DataGridColumnStyle and added the following code to the class: protected RadioButton rb ; ....
6
5062
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I do with the 1st column ? (Below I have a "1" in place for now). Also, Does the datase.AcceptChanges(); updates the changes to the database? Which command do I use to update the changes in dataset back to the Access database table? Thanks, Alpha...
0
4090
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL, TYPE VARCHAR(30) NOT NULL, DURATION TIME , YEAR_RELEASE YEAR NOT NULL, DESCRIPTION TEXT,
23
2881
by: Gary Wessle | last post by:
Hi I have a vector<charwhich looks like this (a d d d a d s g e d d d d d k) I need to get the biggest count of consecutive 'd'. 5 in this example I am toying with this method but not sure if it is optimal. thanks int k = 0;
5
5503
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID are uniqueidentifier columns. My questions: - is Type="Object", below, necessary? - what shall I specify for DefaultValue in my function? I tried everything.
6
5970
by: Jay | last post by:
I need to convert from a string a double that is followed by a scaling character (k means *1e3, M=*1e6, etc) then apply the scaling character. Example: "-1.345k #comment" I know roughly how to do this in C (using the %n in the sscanf format specifier to find the number of characters converted) , but how do I do it in C#? My problem is how to count the number of characters of the double (chpos in the C example) so that the scaling...
0
2089
by: Joe Meng | last post by:
Greetings, I've seen this question asked and answered here, just not completely yet. I'm wondering how to use a column value as a table name in another query. So far it's looking like you must use dynamic SQL, external to DB2. An example: TableX contains column TabName, which is populated by the names of tables in the database. Each of these named tables contains a field called "VID". I wish to match some value of VID in each of...
1
1784
by: Byomokesh | last post by:
Hi I am trying to cell count and match in tgroup cols value in XML file. if cell count and tgrou cols value is mismatch, its showing error. My xml -------------- <tgroup cols="3"> <colspec colnum="1" colname="col1"/> <colspec colnum="2" colname="col2"/> <colspec colnum="3" colname="col3"/>
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.