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

Discussion in 'PHP' started by mokimofiki, Aug 24, 2008.

  1. #1
    Does anyone know what this error could be referring to?
    Error: Column count doesn't match value count at row 1

    I have checked my code over and over and it seems right is this mySQL or the php giving this error?

    It comes up when I hit submit on a form. Below is the form and then the page that is supposed to add it to the mysql table.

    <form action="registerbridge.php" method="post">
    First Name: <input type="text" name="fname"><br>
    Last Name: <input type="text" name="lname"><br>
    Email: <input type="text" name="email"><br>
    Country: <input type="text" name="country"><br>
    <br>
    Gangsters Name: <input type="text" name="pname"><bR>
    Password: <input type="password" name="pword"><br>
    Referred by: <input type="text" name="referal"><br>
    <input type="submit" value="Register">
    </form>
    Code (markup):
    <?php
    $dbserver = "localhost";
    $dblogin = "xxxxxxx";
    $dbpassword = "xxxxxxxx";
    $dbname = "xxxxxxxx";
    
    $con = mysql_connect("$dbserver","$dblogin","$dbpassword");
    if (!$con)
      {
      die('Could not connect to the mySQL server please contact technical support with the following information: ' . mysql_error());
      } 
      
    mysql_select_db("$dbname", $con);
    
    $sql="INSERT INTO users (playerid, playername, password, email, firstname, lastname, country, referrals)
    VALUES
    ('$_POST[pname]','$_POST[pword]','$_POST[email]','$_POST[fname]','$_POST[lname]','$_POST[country]','$_POST[referrals]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Thank you for registering";
      
    mysql_close($con);
    ?>
    Code (markup):
     
    mokimofiki, Aug 24, 2008 IP
  2. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Tri this:
    <?php
    $dbserver = "localhost";
    $dblogin = "xxxxxxx";
    $dbpassword = "xxxxxxxx";
    $dbname = "xxxxxxxx";
    
    $con = mysql_connect("$dbserver","$dblogin","$dbpassword");
    if (!$con)
      {
      die('Could not connect to the mySQL server please contact technical support with the following information: ' . mysql_error());
      } 
      
    mysql_select_db("$dbname", $con);
    
    $sql="INSERT INTO users (playerid, playername, password, email, firstname, lastname, country, referrals)
    VALUES
    ('','$_POST[pname]','$_POST[pword]','$_POST[email]','$_POST[fname]','$_POST[lname]','$_POST[country]','$_POST[referrals]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Thank you for registering";
      
    mysql_close($con);
    ?>
    PHP:
     
    CarcaBot, Aug 24, 2008 IP
    mokimofiki likes this.
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Of course it was a tiny little overlook ...

    Thank you so much :)
     
    mokimofiki, Aug 24, 2008 IP