vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Column count doesn't match value count at row 1 - View Topic
Topic Rating: *****
Printable View
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


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:
 
  1. <?php
  2. include('top.php');
  3. if($_POST['submit'] =='submit') {
  4. // page was submited
  5. $user =security($_POST['user']);
  6. $pass1 =security($_POST['pass1']);
  7. $pass2 =security($_POST['pass2']);
  8. $email1 =security($_POST['email1']);
  9. $email2 =security($_POST['email2']);
  10. $day =$_POST['day'];
  11. $month =$_POST['month'];
  12. $year =$_POST['year'];
  13. $tos =$_POST['tos'];
  14. $valid =security($_POST['validation']);
  15. $date =krak_time();
  16. $act_time =time();
  17. $birthday =$month." ".$day.",".$year;
  18.  
  19. if(empty($user) || empty($pass1) || empty($pass2) || empty($email1) || empty($email2) ||  empty($valid)) {
  20. $errors[] ="You must fill in all fields.";
  21. }
  22. if(strlen($user) >18 || strlen($user) < 2 ) {
  23. $errors[] ="Your username must be between 2 and 18 characters long!";
  24. }
  25. if(strlen($pass1) >18 || strlen($pass1) < 2 || strlen($pass2) >18 || strlen($pass2) < 2 ) {
  26. $errors[] ="Your password must be between 2 and 18 characters long!";
  27. }
  28. // Create the syntactical validation regular expression
  29.    $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
  30.  
  31.    // Validate the syntax
  32.    if (eregi($regexp, $email1)) {
  33.          $valid_email =1;
  34.    } else {
  35.        $valid_email =0;
  36.    }
  37.    // Validate the syntax
  38.    if (eregi($regexp, $email2)) {
  39.          $valid_email =1;
  40.    } else {
  41.        $valid_email =0;
  42.    }
  43. if($valid_email ==0) {
  44. $errors[] ="Your emails must be valid.";
  45. }
  46. if($email1 != $email2) {
  47. $errors[] ="Your emails must match.";
  48. }
  49. if($pass1 != $pass2) {
  50. $errors[] ="Your emails must be valid.";
  51. }
  52. if($day =='00' || $year =='00' || $month =='00') {
  53. $errors[] ="Please choose your birthday.";
  54. }
  55. if($valid !='5') {
  56. $errors[] ="You must provide the right answer for 1+4.";
  57. }
  58. // end the check if submitted
  59. }
  60. echo "<div id='itemTitleBg'>Register</div><div id='itemMiddleBg'>";
  61.  
  62. if(count($errors) !=0) {
  63. echo "Errors:<ul>";
  64. foreach($errors as $e) {
  65. echo "<li>".$e."</li>";
  66. }
  67. echo "</ul>";
  68. }
  69. if($_POST['submit'] !='submit' || count($errors) !=0) {
  70. ?>
  71.  
  72. <form action='index.php?action=register' method='post'>
  73. <table width='100%' cellspacing='0' cellpadding='1' border='0'>
  74. <tr>
  75. <td>Username:</td>
  76. <td><input type='text' name='user' value='<?php echo $user;?>'></td>
  77. <td class='info-text'>This will be your unique name on Kraklak.com</td>
  78. </tr>
  79. <tr>
  80. <td>Password:</td>
  81. <td><input type='password' name='pass1' value='<?php echo $pass2;?>'></td>
  82. <td class='info-text'>Your password to login to your account.(How to choose a good password click <a href='#'>here</a></td>
  83. </tr>
  84. <tr>
  85. <td>Password<font size='1'>(Repeat)</font>:</td>
  86. <td><input type='password' name='pass2' value='<?php echo $pass1;?>'></td>
  87. <td class='info-text'>Repeat your password</td>
  88. </tr>
  89. <tr>
  90. <td>Email:</td>
  91. <td><input type='text' name='email1' value='<?php echo $email1;?>'></td>
  92. <td class='info-text'>Please enter a valid email so forum administrators may contact you.</td>
  93. </tr>
  94. <td>Email<font size='1'>(Repeat)</font>:</td>
  95. <td><input type='text' name='email2' value='<?php echo $email2;?>'></td>
  96. <td class='info-text'>Please enter a valid email so forum administrators may contact you.</td>
  97. </tr>
  98. <tr>
  99. <td>Birthday</td>
  100. <td><select name="day">
  101. <option value='00'>--Day--</option>
  102. <?php
  103. for ( $i = 1; $i <= 31; $i += 1) {
  104.  
  105. echo "<option name='".$i."'";
  106. if($day ==$i) {
  107. echo " selected='1'";
  108. }
  109. echo ">".$i."</option>";
  110. }
  111. ?>
  112. </select><br />
  113. <?php
  114. $months ="January February March April May June July August September October November December";
  115. echo "<select name='month'>
  116. <option value='00'>--Month--</option>";
  117. foreach(explode(" ", $months) as $m) {
  118. echo "<option value='".$m."'";
  119. if($month ==$m) {
  120. echo "selected='1'";
  121. }
  122. echo ">".$m."</option>";
  123. }
  124. ?>
  125.  
  126. </select><br />
  127. <select name="year">
  128. <option value='00'>--Year--</option>
  129. <?php
  130. for ( $i = 95; $i >= 10; $i -= 1) {
  131. echo "<option name='19".$i."'";
  132. if($year =="19".$i) {
  133. echo " selected='1'";
  134. }
  135. echo ">19".$i."</option>";
  136. }
  137. ?>
  138. </select>
  139. </td>
  140. <td class='info-text'>Enter your birthday</td>
  141. </tr>
  142. <tr>
  143. <td>Validation</td>
  144. <td><input type='text' name='validation' value='<?php echo $valid;?>'></td>
  145. <td class='info-text'>What is 1+4?</td>
  146. <tr>
  147. <td><input type='submit' name='submit' value='submit'></td>
  148. <td><input type='reset'></td>
  149. <td></td>
  150. </tr>
  151. </table>
  152. </form>
  153. </div>
  154. <?php
  155. } else {
  156. //submit the info
  157. $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());
  158. if($insert) {
  159. echo "Thank you for registering at Kraklak.com!";
  160. }
  161. }
  162. include('bottom.php');
  163. ?>
  164.  
  165.  
  166.  
 


Also if you see any other ways to make things faster or bugs or improvements just say something.


Image
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


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]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
asdfasdfasdf (12th Mar 08 at 1:07am UTC)
{Smile}


Thanks Marc


Image
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: Column count doesn't match value count at (12th Mar 08 at 1:58am UTC)
No worries. {Smile}

rroll.to— Shorten a link, rickroll your friends.
 Printable View

All times are GMT+0 :: The current time is 8:01am
Page generated in 1.3503 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums