Question : Fields not being read from CSV

When uploading a CSV with just 93 rows, the first 16 rows go smoothly until the 17th row.  

This is the 16th row (which works, perfectly):
string(625) "'1592', '203', 'UNUSED', '', '', '0', 'NTTQ4040E6-N', 'NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (UNUSED) - NORTEL WLAN', 'ReLogisTechs offers a full line of Nortel WLAN products, such as the NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (UNUSED) - NORTEL WLAN.  If you are looking for any additional Nortel WLAN products that are not list on www.relogistechs.com or you have additional questions about the NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (UNUSED) - NORTEL WLAN, please call or contact us today.', '', '', 'NTTQ4040E6-N', '', '', '5', '10', '8', '6', '', '', '', ''"

This is the 17th row (which fails):
string(629) "'1593', '203', 'Refurbished', '', '', '0', 'NTTQ4040E6-R', 'NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (Refurbished) - NORTEL WLAN', 'ReLogisTechs offers a full line of Nortel WLAN products, such as the NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (Refurbished) - NORTEL WLAN.  If you are looking for any additional Nortel WLAN products that are not list on www.relogistechs.com or you have additional questions about the NTTQ4040E6 - WLAN Handset 61xx Belt Clip Ratchet Accessory  (Refurbished) - NORTEL WLAN, please call or contact us today.', '', '', 'NTTQ4040E6-R', '', '', '5', '10', '8', '6'"

Notice, the 16th row has four blank values at the end.  The 17th row does not.  Why does the 17th row omit these values thus creating the error below:

Mysql errno:  1136
Mysql error:  Column count doesn't match value count at row 1
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
// ESCAPE THE INFORMATION FOR USE IN THE QUERY
				foreach ($csvdata as $ptr => $value)
				{
					$csvdata[$ptr] = mysql_real_escape_string($value);
				}
			
				// SET UP VALUE FIELDS
				$query_data = "'" . implode("', '", $csvdata) . "'";
				print "<pre>";
				var_dump($query_data);
				print "</pre>";
				$query_data = str_replace("''", "NULL", $query_data);
			
				// SET UP A QUERY
				$sql = "REPLACE INTO items ( $query_cols ) VALUES ( $query_data )";

Answer : Fields not being read from CSV

Sorry, I send my post incomplete...
1:
2:
$query_data = str_replace("''", "NULL", $query_data);
$query_data.= str_repeat(', NULL', count(explode(',',$query_cols))-count($csvdata))
Random Solutions  
 
programming4us programming4us