954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help with error: Column count doesn't match value count at row 1

HI There

This is the error I am receiving when trying to register on the site:

Column count doesn't match value count at row 1
error: failed to execute query INSERT INTO users (uname,uteln,umail,ustre,usubu,ucity,uprov,ucode,uuser,upass,uc_dt) VALUES

This is the regi.php coding. I cannot figure out the problem


<?php
if (isset($_POST['register'])) {
$query = "INSERT INTO users (uname,uteln,umail,ustre,usubu,ucity,uprov,ucode,uuser,upass,uc_dt) ".
"VALUES ('".$_POST['name']."','".$_POST['teln']."','".$_POST['mail']."','".$_POST['stre']."',".
"'".$_POST['subu']."','".$_POST['city']."','".$_POST['prov']."','".$_POST['code']."',".
"'".$_POST['user']."','".$_POST['pass']."','".date('Y-m-d H:i:s')."',uacti=2)";
$result = mysql_query($query)
or die(mysql_error()."
error: failed to execute query $query");
mail('ndtsales@mweb.co.za','New User','New user requires activation.');
?>

Thank you for your registration.

Your account requires activation.

Once your account has been approved. You will be notified and will be able to continue shopping.

<?php
} else {
?>


Registration

Contact Details

Full Name

Contact Number

E-Mail Address

Delivery Details

Street

Suburb

City

Province

Code

Login Details

Login User Name

Login Password

 





<?php
} // end if
?>

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

You have specified 11 columns, and 12 values, make sure they match.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Hi

Thanks!!

Could you be more specific and perhaps highlight the code?
I am quite new to this and i am editing the code of another developer...

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 
$query = "INSERT INTO users (
  uname, //  1
  uteln, //  2
  umail, //  3
  ustre, //  4
  usubu, //  5
  ucity, //  6
  uprov, //  7
  ucode, //  8
  uuser, //  9
  upass, // 10
  uc_dt  // 11
) VALUES ('" .
  $_POST['name'] . "','" .  //  1
  $_POST['teln'] . "','" .  //  2 
  $_POST['mail'] . "','" .  //  3
  $_POST['stre'] . "','" .  //  4
  $_POST['subu'] . "','" .  //  5
  $_POST['city'] . "','" .  //  6
  $_POST['prov'] . "','" .  //  7
  $_POST['code'] . "','" .  //  8
  $_POST['user'] . "','" .  //  9
  $_POST['pass'] . "','" .  // 10
  date('Y-m-d H:i:s') . "', // 11
  uacti=2                   // here is your problem, guessing uacti should be in the columns, and 2 here
)";
pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

AWESOME!!

Fixed!!

THANKS A MILLION!!! :-D

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

Please mark this thread solved.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You