Multi dimensional array and CSV
Posted: Wed May 12, 2010 4:26 am
Hi,
I used to have the code: the CSV is specified in another php file I can upload it if needed
and it worked 100%
but i needed to make some changes and are using a multi dimensional array now:
But at the new code the values in $sql are empty and not being filled anymore.
Can someone see what I'm doing wrong ?
I used to have the code: the CSV is specified in another php file I can upload it if needed
Code: Select all
$data = fgetcsv ($fp, 2000, ",")
$sql='INSERT INTO test (`name`)
VALUES (\''.mysql_real_escape_string($data[]).'\')';
echo $sql."<br>";
exit();
but i needed to make some changes and are using a multi dimensional array now:
Code: Select all
$rowcount = 0;
$data[$rowcount][] = fgetcsv ($fp, 2000, ",")
$sql='INSERT INTO test (`name`)
VALUES (\''.mysql_real_escape_string($data[$rowcount][0]).'\')';
echo $sql."<br>";
exit();
Can someone see what I'm doing wrong ?