Jump to content

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


billshackle

Recommended Posts

I have the following error: Column count doesn't match value count at row 1

with this script. i can't seem to find anything obvious in my script that causes this - if anyone could shed light. Would appreciate it.

Script:

[code]<? $username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if (isset($_POST['Submit'])) {

        $vid = $_POST['vid'];
        $name = $_POST['name'];
        $uid = $_POST['uid'];
        $q1 = $_POST['q1'];
        $q2 = $_POST['q2'];
        $q3 = $_POST['q3'];
        $q4 = $_POST['q4'];
        $q5 = $_POST['q5'];
        $comments = $_POST['comments'];
        $q6 = $_POST['q6'];

        $query = "INSERT INTO `survey` ( `vid` , `uid` , `name` , `q1` , `q2` , `q3` , `q4` , `q5` , `comments` , `q6` )";


        mysql_query($query) or die (mysql_error());
}
?>
      <form action="rating.php" method="post">
<body>
<table width="604" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="4">
  <tr>
    <td>Name:
      <br>
      <input name="name" type="text" />
      <br />
    <td>
    
    <td>UID:<br>
      <input type="uid" name="uid" value="<? echo $id; ?>">
    <td>    
  <tr>    </tr><tr>
    <td colspan="4"></td>
  </tr>
  <tr>
    <td width="156">
    <select name="q1">
     <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></form></td>
    <td colspan="3"><label></label></td>
  </tr>
  <tr>
    <td colspan="4">What?</td>
  </tr>
  <tr>
    <td>
    <select name="q2">
     <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></form></td>
    <td width="118">&nbsp;</td>
    <td width="316" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">What?</td>
  </tr>
  <tr>
    <td>
    <select name="q3">
       <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></form></td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">What?</td>
  </tr>
  <tr>
    <td>

    <select name="q4">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></form></td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">What?</td>
  </tr>
  <tr>
    <td>
    <select name="q5">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></form></td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">Comments:</td>
  </tr>
  <tr>
    <td colspan="4">
      <textarea name="comments" cols="80" rows="4"></textarea>    </td>
  </tr>
  <tr>
    <td colspan="4">What?</td>
  </tr>
  <tr>
    <td>
    <select name="q6">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select><input name="Submit" type="Submit" />
    <p>
    </form></td>
    <td></td>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
</p>
</body>
</html>[/code]
Link to comment
Share on other sites

Change:

[code]$query = "INSERT INTO `survey` ( `vid` , `uid` , `name` , `q1` , `q2` , `q3` , `q4` , `q5` , `comments` , `q6` )";[/code]

To:

[code]$query = "INSERT INTO survey ('vid' , 'uid' , 'name' , 'q1' , 'q2' , 'q3' , 'q4' , 'q5' , 'comments' , 'q6') VALUES ('$vid', '$name', '$uid', '$q1', '$q2', '$q3', '$q4', '$q5', '$comments', '$q6')";[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.