vForums Support :: Programming & Coding :: Programming Discussion :: Column count doesn't match value count at row 1 - View Topic
 |  |
| Dylan Junior Member
 
![[Avatar]](http://corexhost.com/advertisements/corexhostavatar.gif) Posts: 136 Status: Offline Gender: Male Joined:
pmwwwmsnaimxfire | Column count doesn't match value count at row 1 (12th Mar 08 at 1:03am UTC) PHP mysql error i'm getting | | Column count doesn't match value count at row 1
Thats the error
heres the code
 Code: - <?php
- include('top.php');
- if($_POST['submit'] =='submit') {
- // page was submited
- $user =security($_POST['user']);
- $pass1 =security($_POST['pass1']);
- $pass2 =security($_POST['pass2']);
- $email1 =security($_POST['email1']);
- $email2 =security($_POST['email2']);
- $day =$_POST['day'];
- $month =$_POST['month'];
- $year =$_POST['year'];
- $tos =$_POST['tos'];
- $valid =security($_POST['validation']);
- $date =krak_time();
- $act_time =time();
- $birthday =$month." ".$day.",".$year;
-
- if(empty($user) || empty($pass1) || empty($pass2) || empty($email1) || empty($email2) || empty($valid)) {
- $errors[] ="You must fill in all fields.";
- }
- if(strlen($user) >18 || strlen($user) < 2 ) {
- $errors[] ="Your username must be between 2 and 18 characters long!";
- }
- if(strlen($pass1) >18 || strlen($pass1) < 2 || strlen($pass2) >18 || strlen($pass2) < 2 ) {
- $errors[] ="Your password must be between 2 and 18 characters long!";
- }
- // Create the syntactical validation regular expression
- $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
-
- // Validate the syntax
- if (eregi($regexp, $email1)) {
- $valid_email =1;
- } else {
- $valid_email =0;
- }
- // Validate the syntax
- if (eregi($regexp, $email2)) {
- $valid_email =1;
- } else {
- $valid_email =0;
- }
- if($valid_email ==0) {
- $errors[] ="Your emails must be valid.";
- }
- if($email1 != $email2) {
- $errors[] ="Your emails must match.";
- }
- if($pass1 != $pass2) {
- $errors[] ="Your emails must be valid.";
- }
- if($day =='00' || $year =='00' || $month =='00') {
- $errors[] ="Please choose your birthday.";
- }
- if($valid !='5') {
- $errors[] ="You must provide the right answer for 1+4.";
- }
- // end the check if submitted
- }
- echo "<div id='itemTitleBg'>Register</div><div id='itemMiddleBg'>";
-
- if(count($errors) !=0) {
- echo "Errors:<ul>";
- foreach($errors as $e) {
- echo "<li>".$e."</li>";
- }
- echo "</ul>";
- }
- if($_POST['submit'] !='submit' || count($errors) !=0) {
- ?>
-
- <form action='index.php?action=register' method='post'>
- <table width='100%' cellspacing='0' cellpadding='1' border='0'>
- <tr>
- <td>Username:</td>
- <td><input type='text' name='user' value='<?php echo $user;?>'></td>
- <td class='info-text'>This will be your unique name on Kraklak.com</td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type='password' name='pass1' value='<?php echo $pass2;?>'></td>
- <td class='info-text'>Your password to login to your account.(How to choose a good password click <a href='#'>here</a></td>
- </tr>
- <tr>
- <td>Password<font size='1'>(Repeat)</font>:</td>
- <td><input type='password' name='pass2' value='<?php echo $pass1;?>'></td>
- <td class='info-text'>Repeat your password</td>
- </tr>
- <tr>
- <td>Email:</td>
- <td><input type='text' name='email1' value='<?php echo $email1;?>'></td>
- <td class='info-text'>Please enter a valid email so forum administrators may contact you.</td>
- </tr>
- <td>Email<font size='1'>(Repeat)</font>:</td>
- <td><input type='text' name='email2' value='<?php echo $email2;?>'></td>
- <td class='info-text'>Please enter a valid email so forum administrators may contact you.</td>
- </tr>
- <tr>
- <td>Birthday</td>
- <td><select name="day">
- <option value='00'>--Day--</option>
- <?php
- for ( $i = 1; $i <= 31; $i += 1) {
-
- echo "<option name='".$i."'";
- if($day ==$i) {
- echo " selected='1'";
- }
- echo ">".$i."</option>";
- }
- ?>
- </select><br />
- <?php
- $months ="January February March April May June July August September October November December";
- echo "<select name='month'>
- <option value='00'>--Month--</option>";
- foreach(explode(" ", $months) as $m) {
- echo "<option value='".$m."'";
- if($month ==$m) {
- echo "selected='1'";
- }
- echo ">".$m."</option>";
- }
- ?>
-
- </select><br />
- <select name="year">
- <option value='00'>--Year--</option>
- <?php
- for ( $i = 95; $i >= 10; $i -= 1) {
- echo "<option name='19".$i."'";
- if($year =="19".$i) {
- echo " selected='1'";
- }
- echo ">19".$i."</option>";
- }
- ?>
- </select>
- </td>
- <td class='info-text'>Enter your birthday</td>
- </tr>
- <tr>
- <td>Validation</td>
- <td><input type='text' name='validation' value='<?php echo $valid;?>'></td>
- <td class='info-text'>What is 1+4?</td>
- <tr>
- <td><input type='submit' name='submit' value='submit'></td>
- <td><input type='reset'></td>
- <td></td>
- </tr>
- </table>
- </form>
- </div>
- <?php
- } else {
- //submit the info
- $insert =mysql_query("INSERT INTO users (user, act_code, password, display, rank, email, birthday, reg_date, act_time, last_log, last_act) VALUES('$user', '$pass1', '$user', '1', '$email1', '$birthday', '$date', '$act_time', '$date', '$date')") or die(mysql_error());
- if($insert) {
- echo "Thank you for registering at Kraklak.com!";
- }
- }
- include('bottom.php');
- ?>
-
-
-
Also if you see any other ways to make things faster or bugs or improvements just say something. | |
|
| Marc vChat Developer
     I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
  
pmwww | Re: Column count doesn't match value count at (12th Mar 08 at 1:05am UTC) | | On line 158, you're inserting to 11 columns but only giving 10 values. | |
rroll.to— Shorten a link, rickroll your friends. |
| Dylan Junior Member
 
![[Avatar]](http://corexhost.com/advertisements/corexhostavatar.gif) Posts: 136 Status: Offline Gender: Male Joined:
pmwwwmsnaimxfire | asdfasdfasdf (12th Mar 08 at 1:07am UTC) | |
Thanks Marc | |
|
| Marc vChat Developer
     I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
  
pmwww | Re: Column count doesn't match value count at (12th Mar 08 at 1:58am UTC) | | No worries. | |
rroll.to— Shorten a link, rickroll your friends. |
| |
 |  |
|