Jump to content

Column count doesn't match value count at row 1

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
msebar

msebar

    Newbie

  • Members
  • Pip
  • 5 posts
I went through most of your other post with the same problem but I can't find an issue with mine. Here is the code please help. I do have one more field in the table which is the id field (auto incremnet) I deleted the field in my database and still the same problem.
Thanks Mike
<?php

mysql_connect('localhost','user','password') or die(mysql_error()) ;
mysql_select_db('database');

$filename = "upload/uploadfile.csv";
$handle = fopen("$filename", "r");

    while ((@$data = fgetcsv($handle, 1000, "|")) !== FALSE) {
    $fname=str_replace("'","",$data[0]);
    $lname=str_replace("'","",$data[1]);
    $address=str_replace("'","",$data[2]);
    $city=str_replace("'","",$data[3]);      
    $state=str_replace("'","",$data[4]);    
    $zip=str_replace("'","",$data[5]);    
    $email=str_replace("'","",$data[6]);            
    $source=str_replace("'","",$data[7]);    
    $ip=str_replace("'","",$data[8]);    
    $date_time_stamp=str_replace("'","",$data[9]); 
		

$sql = "INSERT INTO contacts
(
fname,
lname,
address,
city,
state,
zip,
email,
source,
ip,
date_time_stamp
)
values 
('" .
$fname . "','" .
$lname . "','" .
$address . "','" .
$city . "','" .
$state . "')";
$zip . "')";
$email . "')";
$source . "')";
$ip . "')";
$date_time_stamp . "')";

mysql_query($sql) or die(mysql_error());


}

mysql_close();

?>

Edited by Orjan, 29 December 2009 - 05:32 AM.
Please use code or php tag when posting source


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
The problem is that you have alot of ending parenthesis in your query, where it should be commas. Only after the last value there should be a parenthesis.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
msebar

msebar

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks that worked. I have to stop working late nights. The code started to blur around midnight.closedeyes: