www.webdeveloper.com
Results 1 to 7 of 7

Thread: Error: Column count doesn't match value count at row 1??

  1. #1
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    45

    Error: Column count doesn't match value count at row 1??

    when i insert data into DB it shows me error like Error: Column count doesn't match value count at row 1....my php code is

    <?php
    $con=mysqli_connect("abc.com","college","College","college");
    // Check connection
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $sql="INSERT INTO student (firstname,lastname, class, rollnum, marks, attendance)
    VALUES
    ('$_POST[firstname]','$_POST[lastname]','$_POST[class]''$_POST[rollnum]','$_POST[marks]','$_POST[attendance]')";

    if (!mysqli_query($con,$sql))
    {
    die('Error: ' . mysqli_error($con));
    }
    echo "1 record added";

    mysqli_close($con);
    ?>
    PR 2 Do-f0llow links

    like my sites i'll like your choice

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    752
    As the message says the number of columns (fieldnames) that you have in your query statement does not match the number of values you want inserted into those columns. The reason is the missing comma

  3. #3
    Join Date
    Feb 2014
    Location
    England
    Posts
    52
    You have a comma missing in your SQL statement.

    INSERT INTO student (firstname,lastname, class, rollnum, marks, attendance)
    VALUES
    ('$_POST[firstname]','$_POST[lastname]','$_POST[class]''$_POST[rollnum]','$_POST[marks]','$_POST[attendance]')

    Between the class and rollnum values.

  4. #4
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    45
    thanks bro....i got it...
    PR 2 Do-f0llow links

    like my sites i'll like your choice

  5. #5
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    45
    how can i enter alphanumeric data in a field>>??what is that data type i have to write??
    PR 2 Do-f0llow links

    like my sites i'll like your choice

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    752
    Come on - have you not done any php learning? Do you expect this forum to answer everything you don't know?

    Here's a clue - php is a type-less language.

  7. #7
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    45
    okay..thanks dear.
    PR 2 Do-f0llow links

    like my sites i'll like your choice

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles