列数与第1行的值计数不匹配 - 但列数正确[重复]

This question already has an answer here:

I have the following code that creates a database table and then should insert 6 columns of data into the table, but it does not insert the data into the table.

I get the following error:

Column count doesn't match value count at row 1

Below is the code and a print_r of the array data that should be inserted into the table:

Any help would be appreciated, thank you.

       // Database Authentication-user, password
          $TableName = 'User_Data';
          $dbh = mysql_connect ("localhost", "username", "password")
          or die ('Cannot connect to the database because: ' . mysql_error());

          mysql_select_db ("database");

       // Creates Database Table if it does not exist
          if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$TableName."'")) != 1) {
           mysql_query("CREATE TABLE $TableName(
         id INT NOT NULL AUTO_INCREMENT,
         PRIMARY KEY (id),
         Topic                varchar(300) NOT NULL default '',
         Post_Date            varchar(100) NOT NULL default '',
         Phone_Number         varchar(100) NOT NULL default '',
         Original_Description varchar(2000) NOT NULL default '',
         Alt_Description      varchar(2000) NOT NULL default '',
         Website_Link         varchar(2000) NOT NULL default '') ") or die(mysql_error());
          }

       // Write to MySQL Database
          $queries = array(); 
          for($i=0; $i<count($current_topic_array); $i++) {
             $queries[] = '(
             '.$current_topic_array[$i].',
             '.$post_date_array[$i].',
             '.$phone_array[$i].',
             '.$original_description_array[$i].',
             '.$alt_description_array[$i].',
             '.$website_link_array[$i].'
             )'; 
          }

          echo '<pre>';
          print_r($queries);
          echo '</pre>';

          mysql_query("insert into $TableName (Topic, Post_Date, Phone_Number, Original_Description, Alt_Description, Website_Link)
          values (". implode(',', $queries) . ")") or die(mysql_error());


Array
(
    [0] => (
               'Classic Cars',
               '05-02-2012',
               '777-555-1212',
               'Classic Car show held in Spring of May 2012',
               'Classic Car May 2012',
               'http://website.com/post/864.html'
               )
    [1] => (
               'Classic Cars',
               '07-13-2012',
               '777-555-5412',
               'Classic Car show held in Summer of July 2012',
               'Classic Car July 2012',
               'http://website.com/post/865.html'
               )
    etc...
)
</div>

If you columns are VARCHARs and hence you are expecting to receive string values you need to wrap your values in single-quotes. The easiest way to do this as all your columns are strings would be

mysql_query("insert into $TableName (Topic, Post_Date, Phone_Number, Original_Description, Alt_Description, Website_Link)
      values ('". implode("','", $queries) . "')") or die(mysql_error());

Although you should probably investigate PDO as it does it for you.

EDIT Try refactoring the code like this

$sql = "insert into $TableName (Topic, Post_Date, Phone_Number, Original_Description, Alt_Description, Website_Link)
      values ('". implode("','", $queries) . "')";
mysql_query( $sql ) or die(mysql_error());

You should then be able to echo out the actual query that's being run to see what the problem is.