Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:11:55+00:00 2026-05-27T07:11:55+00:00

I am trying to post into a database table, 3 different bits of information,

  • 0

I am trying to post into a database table, 3 different bits of information, but I get an error of Column count doesn't match value count at row 1

Here’s my database table structure:

    interestID      int(11) auto_increment                          
    name            varchar(100)                                         
    categoryID      int(11)                                  
    interest_desc   varchar(30)                              
    date            timestamp

The form:

<form id="form_design" method="post" action="interesting.php">
    <fieldset id="input_1">
        <input type="text" id="username" value="name?"   />
    </fieldset>            
    <fieldset id="input_2">
        <input type="text" id="interest" value="your interest?"  />
    </fieldset>   
    <fieldset id="input_3>
       <select id="cats">
           <option value="">--</option>
           <?php 
               $sql = "SELECT   categoryID, category_desc FROM categories "."ORDER BY category_desc"; $rs = mysql_query($sql);

               while($row = mysql_fetch_array($rs))
               { 
                   echo "<option value=\"".$row['categoryID']."\">".$row['category_desc']."</option>\n  "; }
?>                                                                        
        </select>
    </fieldset>
    <input type="submit" name="submit" value="Submit" />
</form>

The php that inserts it into the table retrieves a column count doesn’t match value count at row 1

PHP –

$interest_user = $_POST['username'];
$interest_name = $_POST['interest'];
$interest_cats = $_POST['cats'];

mysql_query("INSERT INTO interests ( interestID, name, categoryID
                , interest_desc, date )
             VALUES( "",'$interest_user' '$interest_cats'
                , '$interest_name', "" ) ") 
or die(mysql_error());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:11:56+00:00Added an answer on May 27, 2026 at 7:11 am

    Missing a comma between '$interest_user' '$interest_cats'

    should be

    '$interest_user', '$interest_cats'
    

    more problem :-

    mysql_query("INSERT INTO interests 
    (interestID,name,categoryID,interest_desc,date)  VALUES( "",'$interest_user' 
    '$interest_cats', '$interest_name',""   ) ")
    

    Are you sure you are not getting syntax error?

    Should be :-

    mysql_query("INSERT INTO interests 
    (interestID,name,categoryID,interest_desc,date)  VALUES( '','$interest_user' 
    '$interest_cats', '$interest_name',''   ) ")
    

    Basic problem is solved,
    your way of insertion is vulnerable for SQL injection

    Here are the list you MUST do some reading:- https://stackoverflow.com/search?q=sql+injection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to post data with AJAX and insert it into a database table.
I'm trying to insert information from a form into a database table and then
I am trying to post a game high-score to my database table, but I
Possible Duplicate: outputting values from database into html table PHP I am trying to
I'm trying to POST to a secure site using WinHttp, and running into a
I'm trying to create a post button that inserts the latest posts into a
Sorry for long winded post. I am trying to understand UIScrollView and running into
I'm trying to POST a http request using ajax, but getting a response from
I am trying to insert rows of data in an array into a table.
I am trying to pull data from a table I have imported into my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.