Jump to content

[SOLVED] What does this mean?


Lamez

Recommended Posts

When I run my PHP script I get this error:

 

Column count doesn't match value count at row 1

INSERT INTO `1` VALUES ('1', 'ReagionName', '77', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '99', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'TeamNeame', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')

 

what does it mean? How do I fix it?

Link to comment
Share on other sites

yes I did, I made a function:

 

function add($id, $region, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16){
   $q = "INSERT INTO `1` VALUES ('$id', '$region', '$w1a', '$w2a', '$w3a', '$w4a', '$w5a', '$w5a', '$w6a', '$w7a', '$w8a', '$w9a', '$w10a', '$w11a', '$w12a', '$w13a', '$w14a', '$w15a', '$w16a', '$l1a', '$l2a', '$l3a', '$l4a', '$l5a', '$l6a', '$l7a', '$l8a', '$l9a', '$l10a', '$l11a', '$l12a', '$l13a', '$l14a', '$l15a', '$l16a', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10', '$a11', '$a12', '$a13', '$a14', '$a15', '$a16')";
  if ($result = mysql_query($q)) {
    return $result;
  } else {
    die(mysql_error() . "<br />" . $q);
  }
}

 

and it calls in here:

 

$q = "Select count(*) as row_count from `1` where id=1";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
if(mysql_num_rows($r) >0){
$query = "DELETE FROM `1` WHERE id = 1";
$result = mysql_query($query);
add($id, $region, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16);
}
else{

add($id, $region, $id, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16);

}

 

where did I go wrong?

 

The table name is 1

Link to comment
Share on other sites

I cannot find the my mistake, maybe a pair of fresh eyes will help

 

here is how my table is setup

Table Name: 1

 

id

region

w1a - w16a (w1a, w2a, etc..)

l1a - l16a (l1a, l2a, etc..)

1-16 (1, 2, etc..)

 

 

<?php
/*Connect, and define user*/
include ("../../style/include/session.php");
error_reporting(E_ALL);

/*Define Variables*/
$region = $_POST['region1'];
$id = $_POST['id1'];

$w1a = $_POST['w1a'];
$w2a = $_POST['w2a'];
$w3a = $_POST['w3a'];
$w4a = $_POST['w4a'];
$w5a = $_POST['w5a'];
$w6a = $_POST['w6a'];
$w7a = $_POST['w7a'];
$w8a = $_POST['w8a'];
$w9a = $_POST['w9a'];
$w10a = $_POST['w10a'];
$w11a = $_POST['w11a'];
$w12a = $_POST['w12a'];
$w13a = $_POST['w13a'];
$w14a = $_POST['w14a'];
$w15a = $_POST['w15a'];
$w16a = $_POST['w16a'];

$l1a = $_POST['l1a'];
$l2a = $_POST['l2a'];
$l3a = $_POST['l3a'];
$l4a = $_POST['l4a'];
$l5a = $_POST['l5a'];
$l6a = $_POST['l6a'];
$l7a = $_POST['l7a'];
$l8a = $_POST['l8a'];
$l9a = $_POST['l9a'];
$l10a = $_POST['l10a'];
$l11a = $_POST['l11a'];
$l12a = $_POST['l12a'];
$l13a = $_POST['l13a'];
$l14a = $_POST['l14a'];
$l15a = $_POST['l15a'];
$l16a = $_POST['l16a'];

$a1 = $_POST['1a'];
$a2 = $_POST['2a'];
$a3 = $_POST['3a'];
$a4 = $_POST['4a'];
$a5 = $_POST['5a'];
$a6 = $_POST['6a'];
$a7 = $_POST['7a'];
$a8 = $_POST['8a'];
$a9 = $_POST['9a'];
$a10 = $_POST['10a'];
$a11 = $_POST['11a'];
$a12 = $_POST['12a'];
$a13 = $_POST['13a'];
$a14 = $_POST['14a'];
$a15 = $_POST['15a'];
$a16 = $_POST['16a'];

function add($id, $region, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16)
{
   $q = "INSERT INTO `1` VALUES ('$id', '$region', '$w1a', '$w2a', '$w3a', '$w4a', '$w5a', '$w5a', '$w6a', '$w7a', '$w8a', '$w9a', '$w10a', '$w11a', '$w12a', '$w13a', '$w14a', '$w15a', '$w16a', '$l1a', '$l2a', '$l3a', '$l4a', '$l5a', '$l6a', '$l7a', '$l8a', '$l9a', '$l10a', '$l11a', '$l12a', '$l13a', '$l14a', '$l15a', '$l16a', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10', '$a11', '$a12', '$a13', '$a14', '$a15', '$a16')";
  if ($result = mysql_query($q)) {
    return $result;
  } else {
    die(mysql_error() . "<br />" . $q);
  }
}





$q = "Select count(*) as row_count from `1` where id=1";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
if(mysql_num_rows($r) >0){
//Delete Row
$query = "DELETE FROM `1` WHERE id = 1";
//Add to DB
$result = mysql_query($query);

add($id, $region, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16);
}
else{
//No rows, so add

add($id, $region, $w1a, $w2a, $w3a, $w4a, $w5a, $w6a, $w7a, $w8a, $w9a, $w10a, $w11a, $w12a, $w13a, $w14a, $w15a, $w16a, $l1a, $l2a, $l3a, $l4a, $l5a, $l6a, $l7a, $l8a, $l9a, $l10a, $l11a, $l12a, $l13a, $l14a, $l15a, $l16a, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16);

}
?>

 

anyone see it?

Link to comment
Share on other sites

Use the query as follows

 

<?php

$q = "INSERT INTO `1` VALUES ('$id', '$region', '$w1a', '$w2a', '$w3a', '$w4a', '$w5a', '$w6a', '$w7a', '$w8a', '$w9a', '$w10a', '$w11a', '$w12a', '$w13a', '$w14a', '$w15a', '$w16a', '$l1a', '$l2a', '$l3a', '$l4a', '$l5a', '$l6a', '$l7a', '$l8a', '$l9a', '$l10a', '$l11a', '$l12a', '$l13a', '$l14a', '$l15a', '$l16a', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10', '$a11', '$a12', '$a13', '$a14', '$a15', '$a16')";
  

?>

Cheers

 

Link to comment
Share on other sites

I still get this error

 

Column count doesn't match value count at row 1

INSERT INTO `1` VALUES ('1', 'ReagionName', '77', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '99', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'TeamNeame', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')

Link to comment
Share on other sites

If your only looking to insert data into four rows, specify them. its best practice to always do this anyway.

 

God only knows why you would have a field called 1.

 

INSERT INTO tbl (fld1,fld2,fld3,fld4) VALUES ('val1','val2','val3','val4');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.