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()."<br><b>error</b>: failed to execute query <i>$query</i>");
    mail('ndtsales@mweb.co.za','New User','New user requires activation.');
?>
<center>
   Thank you for your registration.<br />
   Your account requires activation.<br />
   Once your account has been approved.  You will be notified and will be able to continue shopping.
</center>
<?php
} else {
?>
<center>
   <form method='post' action='?page=Registration'>
      <h2 align='left'>Registration</h2>

      <fieldset style='padding: 10px; text-align: left; width: 300px'>
         <legend>Contact Details</legend>

         <label>Full Name </label><br />
         <input type='text' name='name' /><br />

         <label>Contact Number </label><br />
         <input type='text' name='teln' /><br />

         <label>E-Mail Address</label><br />
         <input type='text' name='mail' /><br />
      </fieldset>

      <fieldset style='padding: 10px; text-align: left; width: 300px'>
         <legend>Delivery Details</legend>

         <label>Street</label><br />
         <input type='text' name='stre' /><br />

         <label>Suburb</label><br />
         <input type='text' name='subu' /><br />

         <label>City</label><br />
         <input type='text' name='city' /><br />

         <label>Province</label><br />
         <input type='text' name='prov' /><br />

         <label>Code</label><br />
         <input type='text' name='code' /><br />
      </fieldset>


      <fieldset style='padding: 10px; text-align: left; width: 300px'>
         <legend>Login Details</legend>

         <label>Login User Name</label><br />
         <input type='text' name='user' /><br />

         <label>Login Password</label><br />
         <input type='password' name='pass' /><br />
      </fieldset>

      <p>&nbsp;</p>
      <input type='submit' name='register' value='Register' /> <input type='reset' value='Clear' />
   </form>
</center>
<?php
} // end if
?>

Recommended Answers

All 5 Replies

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

$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
)";

AWESOME!!

Fixed!!

THANKS A MILLION!!! :-D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.