$10 just to fill in whats wrong on this script

Remember, all I need is the info on this, so I am only offering $10 for this one, just take a look, and if you know what I need to change to make it work I will pay you $10:

I have a script for uploading csv files into my MySQL Database tables. The problem is it loads one file into one table, what I need it to do is to mark the columns based on the column name and upload each column to the right table. The 4 tables and the columns they contained I listed below:









And here is a copy of the contents of a one line csv file that would be uploaded, just as an example, in normal effect it will be hundreds of lines, but this is just a single line to show what I mean:



Cooking|Toasters_and_Toaster_Ovens,APW Wyott,AT-Express,AT Express Radiant Conveyor Toasters,ELECTRIC : 120V 1725W 14.4 Amps 60hz DIMENSIONS : 13 1/4inH x 15 3/64inW x 17 3/16inD LBS : 35,[url removed, login to view],[url removed, login to view],,,,,85,"75226 [Dallas, TX]",35,13.25,15.05,17.19,1144

So the base code I use for uploading one file to one database is below, I need to make it work for uploading data from one csv file into separate tables based on the column name.


$fcontents = file ('./[url removed, login to view]');

for($i=0; $i<sizeof($fcontents); $i++) {

$line = trim($fcontents[$i]);

$arr = explode(",", $line);

$sql = "insert into `products` values ('".

implode("','", $arr) ."')";


echo $sql ."<br>n";

if(mysql_error()) {

echo mysql_error() ."<br>n";



Any ideas?

I came up with the following code, but it needs to break the $values up into the right array sets for each sql insert query:


$table_products = "`categories` , `manufacturer`, `model_number`, `list_price` ";

$table_products_description = "`manufacturer` , `model_number`, `description` ";

$table_products_media = "`manufacturer`, `model_number`, `image_file`, `pdf_specs`, `pdf_one`, `pdf_two`, `pdf_three`, `pdf_four` ";

$table_products_ship = "`manufacturer`, `model_number`, `freight_class`, `ship_from`, `weight`, `height`, `width`, `depth` ";

$handle = fopen("product_update.csv", "r");

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

foreach( $data as $v ) {




$sql = "INSERT INTO `products` ( $table_products ) VALUES ( $values )";

mysql_query($sql) or die('SQL ERROR:'.mysql_error());

$sql = "INSERT INTO `products_description` ( $table_products_description ) VALUES ( $values )";

mysql_query($sql) or die('SQL ERROR:'.mysql_error());

$sql = "INSERT INTO `products_media` ( $table_products_media ) VALUES ( $values )";

mysql_query($sql) or die('SQL ERROR:'.mysql_error());

$sql = "INSERT INTO `products_ship` ( $table_products_ship ) VALUES ( $values )";

mysql_query($sql) or die('SQL ERROR:'.mysql_error());



Evner: PHP

Se mere: what is upload mean, to-do categories, sql pdf files, sql code pdf, products offering, problem categories, php dallas, line in problem, foreach in php and mysql, data dimensions, dallas php, c.v. example, at just, linux script probleme, sql r, sql in r, r sql, my sql data base, whats up, V look, Trim, single line, make-jpg-into, LBS, just

Om arbejdsgiveren:
( 28 bedømmelser ) Miami, United States

Projekt ID: #316081

Tildelt til:


There are two errors in the script, I will send you the modification soon.

$30 USD in 0 dage
(282 bedømmelser)

2 freelancere byder i gennemsnit $40 på dette job


hello we are the largest developer of india to create websites and develpoment we have decicated team to hadle these type of project

$50 USD in 4 dage
(15 bedømmelser)