Jump to content

[SOLVED] Error: Column count doesn't match value count at row 1


prcollin

Recommended Posts

it normally means that you are either trying to insert not enough information into the table or too much information. lets say you have a tabvle with 4 columns called tester

 

$query = "INSERT INTO tester VALUES ("a", "b", "c", "d", "e")";

 

would throw an error becasue there are only 4 columns and you are tyring to insert 5 items

How does this code look would you change anything?

 

<?php

include "clientconnect.php";
include "newclient.html";

mysql_select_db('greencut_customercenter', $con);

$client_id = mysql_real_escape_string($_POST['client_id']);
$client_fname = mysql_real_escape_string($_POST['client_fname']);
$client_lname = mysql_real_escape_string($_POST['client_lname']);
$client_address = mysql_real_escape_string($_POST['client_address']);
$client_city = mysql_real_escape_string($_POST['client_city']);
$client_state = mysql_real_escape_string($_POST['client_state']);
$client_zipcode = mysql_real_escape_string($_POST['client_zipcode']);
$client_phone = mysql_real_escape_string($_POST['client_phone']);
$client_cphone = mysql_real_escape_string($_POST['client_cphone']);
$client_email = mysql_real_escape_string($_POST['client_email']);
$client_website = mysql_real_escape_string($_POST['client_website']);
$client_notes = mysql_real_escape_string($_POST['client_notes']);

$sql = "insert into clients values('$client_id', '$client_fname', '$client_lname', '$client_address', '$client_city', '$client_state', '$client_zipcode', '$client_phone', '$client_cphone', '$client_email', '$client_website', '$client_notes',)";


if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";mysql_close($con)
?>



they are a bugger, them itinerant commas, arnt they??  :)

 

yeah they suck but now i have new issues, i keep getting errors about a deplicat entry for key 2.  Cant solve it and its pissing me off, i have tried everything rearranged databse tried code 5 different ways.  BLAH

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.