Lynn Strauch Posted December 14, 2011 Share Posted December 14, 2011 php Hi everyone, New to php and new to the phphelp area. THANK YOU FOR THIS SITE!!! Thank you in advance for any help. Here is the site: https://ninechicago.net/memberSystemBasic/join_form.php The error says: Column count doesn't match value count at row 1 I have looked and looked for the problem but I just can't see it. Here is the php: <?php /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ //Connect to the database through our include include_once "connect_to_mysql.php"; // Filter the posted variables $username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $realname = ereg_replace("[^A-Za-z0-9]", "", $_POST['realname']); // filter everything but numbers and letters $phone = ereg_replace("[^A-Za-z0-9]", "", $_POST['phone']); // filter everything but numbers and letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $address = ereg_replace("[^A-Za-z0-9]", "", $_POST['address']); // filter everything but numbers and letters $city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $zip = ereg_replace("[^A-Z a-z0-9]", "", $_POST['zip']); // filter everything but spaces, numbers, and letters $country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $accounttype = ereg_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters $bio = ereg_replace("[^A-Z a-z0-9]", "", $_POST['bio']); // filter everything but spaces, numbers, and letters $resume = ereg_replace("[^A-Z a-z0-9]", "", $_POST['resume']); // filter everything but spaces, numbers, and letters // email fields...Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if((!$username) || (!$password) || (!$realname) || (!$phone) || (!$email) || (!$city) || (!$state) || (!$zip) || (!$country) || (!$bio)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$username){ $errorMsg .= "--- User Name"; } else if(!$password){ $errorMsg .= "--- Password"; } else if(!$realname){ $errorMsg .= "--- Your Real Name"; } else if(!$email){ $errorMsg .= "--- Email"; } else if(!$address){ $errorMsg .= "--- address"; } else if(!$city){ $errorMsg .= "--- City"; } else if(!$state){ $errorMsg .= "--- State"; } else if(!$zip){ $errorMsg .= "--- Zip"; } else if(!$country){ $errorMsg .= "--- country"; } else if(!$accounttype){ $errorMsg .= "--- Account Type"; } else if(!$bio){ $errorMsg .= "--- Bio"; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (id, username, password, realname, phone, email, address, city, state, zip, country, accounttype, bio, resume, signupdate) VALUES('$username','$realname', '$address','$city','$state','$zip','$country','$accounttype','$email','$hashedPass', now())") or die (mysql_error()); // Get the inserted ID here to use in the activation email $id = mysql_insert_id(); // Create directory(folder) to hold each user files(pics, MP3s, etc.) mkdir("memberFiles/$id", 0755); // Start assembly of Email Member the activation link $to = "$email"; // Change this to your site admin email $from = "admin@ninechicago.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $username . ', <br /><br /> You must complete this step to activate your account with us. <br /><br /> Please click here to activate now >> <a href="http://www.ninechicago.net/memberSystemBasic/activation.php?id=' . $id . '"> ACTIVATE NOW</a> <br /><br /> Your Login Data is as follows: <br /><br /> E-mail Address: ' . $email . ' <br /> Password: ' . $password . ' <br /><br /> Thanks! </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check } //Close if $_POST ?> Quote Link to comment https://forums.phpfreaks.com/topic/253158--/ Share on other sites More sharing options...
marcelobm Posted December 14, 2011 Share Posted December 14, 2011 In this INSERT Statement you are passing 15 column names and only 11 column values, it must be the same $sql = mysql_query("INSERT INTO members (id, username, password, realname, phone, email, address, city, state, zip, country, accounttype, bio, resume, signupdate) VALUES('$username','$realname', '$address','$city','$state','$zip','$country','$accounttype','$email','$hashedPass', now())") or die (mysql_error()); for example INSERT INTO members (username, password, realname, phone, email, address, city, state, zip) VALUES ('$username', '$password', '$realname', '$phone', '$email', '$address', '$city', '$state', '$zip') Same number of parameters in the same order. Quote Link to comment https://forums.phpfreaks.com/topic/253158--/#findComment-1297821 Share on other sites More sharing options...
MikeDean89 Posted December 14, 2011 Share Posted December 14, 2011 Your error is relating to the following line: $sql = mysql_query("INSERT INTO members (id, username, password, realname, phone, email, address, city, state, zip, country, accounttype, bio, resume, signupdate) VALUES('$username','$realname', '$address','$city','$state','$zip','$country','$accounttype','$email','$hashedPass', now())") or die (mysql_error()); When inserting into a table, your columns must match the values being inserted. It also needs to be in the same order, see example MySQL query below: INSERT INTO table (col1, col2, col3, col4) VALUES (val1, val2, val3, val4) To fix your query, you'd need to add the remaining values to your query and reorder them. $sql = mysql_query("INSERT INTO members (id, username, password, realname, phone, email, address, city, state, zip, country, accounttype, bio, resume, signupdate) VALUES(NULL, '$username', '$hashedPass','$realname', '$phone', '$email', '$address','$city','$state','$zip','$country','$accounttype', '$bio', '$resume', now())") or die (mysql_error()); Note the additional values and the new order of the values to match the column order. Basically what marcelobm said, d'oh! Quote Link to comment https://forums.phpfreaks.com/topic/253158--/#findComment-1297822 Share on other sites More sharing options...
Lynn Strauch Posted December 14, 2011 Author Share Posted December 14, 2011 YOU GUYS ROCK. I looked at it after I sent this ??? and changed the code like you had, but STILL had an error. Now I did it your way, and it WORKED! Thank you, Thank you, Thank You! Quote Link to comment https://forums.phpfreaks.com/topic/253158--/#findComment-1297828 Share on other sites More sharing options...
Lynn Strauch Posted December 14, 2011 Author Share Posted December 14, 2011 May I ask one more question? The Candidate area is working PERFECTLY. However, now my Employer area is sort of working, but not completely. The issue is: When the emails sends for them to activate, it says Your account could not be activated. Sigh. I am sorry about this guys. I apologize to you amazing coders!!! Here is the code for the employers section on: https://ninechicago.net/EmployersDB/join_form.php <?php /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ //Connect to the database through our include include_once "connect_to_mysql.php"; // Filter the posted variables $username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $realname = ereg_replace("[^A-Za-z0-9]", "", $_POST['realname']); // filter everything but numbers and letters $company = ereg_replace("[^A-Za-z0-9]", "", $_POST['company']); // filter everything but numbers and letters $title = ereg_replace("[^A-Za-z0-9]", "", $_POST['title']); // filter everything but numbers and letters $phone = ereg_replace("[^A-Za-z0-9]", "", $_POST['phone']); // filter everything but numbers and letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $address = ereg_replace("[^A-Za-z0-9]", "", $_POST['address']); // filter everything but numbers and letters $city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $zip = ereg_replace("[^A-Z a-z0-9]", "", $_POST['zip']); // filter everything but spaces, numbers, and letters $country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $accounttype = ereg_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters $bio = ereg_replace("[^A-Z a-z0-9]", "", $_POST['bio']); // filter everything but spaces, numbers, and letters $resume = ereg_replace("[^A-Z a-z0-9]", "", $_POST['resume']); // filter everything but spaces, numbers, and letters // email fields...Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if((!$username) || (!$password) || (!$realname) || (!$company) || (!$title) || (!$phone) || (!$email) || (!$city) || (!$state) || (!$zip) || (!$country) || (!$bio)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$username){ $errorMsg .= "--- User Name"; } else if(!$password){ $errorMsg .= "--- Password"; } else if(!$realname){ $errorMsg .= "--- Your Real Name"; } else if(!$company){ $errorMsg .= "--- Your Company's Name"; } else if(!$title){ $errorMsg .= "--- Your Title"; } else if(!$email){ $errorMsg .= "--- Email"; } else if(!$address){ $errorMsg .= "--- address"; } else if(!$city){ $errorMsg .= "--- City"; } else if(!$state){ $errorMsg .= "--- State"; } else if(!$zip){ $errorMsg .= "--- Zip"; } else if(!$country){ $errorMsg .= "--- country"; } else if(!$accounttype){ $errorMsg .= "--- Account Type"; } else if(!$bio){ $errorMsg .= "--- Bio"; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (id, username, password, realname, company, title, phone, email, address, city, state, zip, country, accounttype, bio, resume, signupdate) VALUES(NULL, '$username', '$hashedPass','$realname', '$company','$title','$phone', '$email', '$address','$city','$state','$zip','$country','$accounttype', '$bio', '$resume', now())") or die (mysql_error()); // Get the inserted ID here to use in the activation email $id = mysql_insert_id(); // Create directory(folder) to hold each user files(pics, MP3s, etc.) mkdir("memberFiles/$id", 0755); // Start assembly of Email Member the activation link $to = "$email"; // Change this to your site admin email $from = "admin@ninechicago.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $username . ', <br /><br /> You must complete this step to activate your account with us. <br /><br /> Please click here to activate now >> <a href="http://www.ninechicago.net/memberSystemBasic/activation.php?id=' . $id . '"> ACTIVATE NOW</a> <br /><br /> Your Login Data is as follows: <br /><br /> E-mail Address: ' . $email . ' <br /> Password: ' . $password . ' <br /><br /> Thanks! </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check } //Close if $_POST ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Member Registration</title> </head> <body> <p><img src="../img/icons/logo.png" alt="Logo" width="286" height="99" /><br /> </p> <hr /> <table width="600" align="center" cellpadding="4"> <tr> <td width="7%"><center> <strong>REGISTER AS A MEMBER HERE </strong> </center> </td> </tr> </table> <table width="600" align="center" cellpadding="5"> <form action="join_form.php" method="post" enctype="multipart/form-data"> <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="left">Preferred Login ID:</div></td> <td width="409"><input name="username" type="text" value="<?php echo "$username"; ?>" /> (your preferred user name) </td> </tr> <tr> <td><div align="left">Password:</div></td> <td><input name="password" type="password" value="<?php echo "$password"; ?>" /></td> </tr> <tr> <td><div align="left">Your Name </div></td> <td><input name="realname" type="text" id="realname" value="<?php echo "$realname"; ?>" /></td> </tr> <tr> <td><div align="left">Company Name: </div></td> <td><input name="company" type="text" id="company" value="<?php echo "$company"; ?>" /></td> </tr> <tr> <td><div align="left">Your Title: </div></td> <td><input name="title" type="text" id="title" value="<?php echo "$title"; ?>" /></td> </tr> <tr> <td><div align="left">Phone: </div></td> <td><input name="phone" type="text" id="phone" value="<?php echo "$phone"; ?>" /></td> </tr> <tr> <td><div align="left">Email:</div></td> <td><input name="email" type="text" id="email" value="<?php echo "$email"; ?>" /></td> </tr> <tr> <td><div align="left">Address: </div></td> <td><input name="address" type="text" id="address" value="<?php echo "$address"; ?>" /></td> </tr> <tr> <td><div align="left">City:</div></td> <td><input name="city" type="text" id="city" value="<?php echo "$city"; ?>" /></td> </tr> <tr> <td><div align="left">State:</div></td> <td><input name="state" type="text" id="state" value="<?php echo "$state"; ?>" /></td> </tr> <tr> <td><div align="left">Zip:</div></td> <td><input name="zip" type="text" id="zip" value="<?php echo "$zip"; ?>" /></td> </tr> <tr> <td><div align="left">Country:</div></td> <td><select name="country"> <option value="<?php echo "$country"; ?>"><?php echo "$country"; ?></option> <option value="Australia">Australia</option> <option value="Canada">Canada</option> <option value="Mexico">Mexico</option> <option value="United Kingdom">United Kingdom</option> <option value="United States" selected="selected">United States</option> <option value="Zimbabwe">Zimbabwe</option> </select></td> </tr> <tr> <td><div align="left">Account Type: </div></td> <td><select name="accounttype"> <option value="<?php echo "$accounttype"; ?>"><?php echo "$accounttype"; ?></option> <option value="a" selected="selected">Employers</option> <option value="b">Recruiter</option> </select></td> </tr> </tr> <tr> <td><div align="left">Company Profile:</div></td> <td><textarea name="bio" cols="30" rows="10" id="bio"><?php echo "$bio"; ?></textarea></td> </tr> <tr> <td><div align="left">Additional Information: </div> <br /></td> <td><textarea name="resume" cols="30" rows="10" id="resume"><?php echo "$resume"; ?></textarea> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> <p> </p> <table width="600" align="center" cellpadding="5"> <form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><center> <font size="3"><strong>Already have an account? <a href="login.php">Login Here</a></strong></font> </center> </td> </tr> </form> </table> </p><br /> <hr /> <div class="footer"> <p><script type="text/javascript"> <!-- Obtained at http://BontragerConnection.com/ // // Auto-Copyright Year Updater // // Copyright 2007 Bontrager Connection, LLC // // Edit as indicated, then paste the JavaScript code // where you want the copyright line to print. // // Between the quotation marks, below, type the entire // copyright line for your web page. Where the current // year is to be placed, type: [[YEAR]] // If the copyright line contains any quotation marks, they // must be escaped with a backslash: \" // Example: // Copyright 2004-[[YEAR]] Person, Inc. var CopyrightLine = "<p><center>Copyright 2007-[[YEAR]] NINE Chicago. All Rights Reserved.</center></p>"; // No edits required below this point. y = new Date(); year = y.getFullYear(); re = new RegExp("\\[\\[YEAR\\]\\]"); CopyrightLine = CopyrightLine.replace(re,year); document.write(CopyrightLine); //--> </script></p> </div> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-2280256-12"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253158--/#findComment-1297851 Share on other sites More sharing options...
Maq Posted December 14, 2011 Share Posted December 14, 2011 In the future, please place OR tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/253158--/#findComment-1297865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.