Hi All,
I'm building a script to extract data from a csv file and import it into a database, I made a script previously which worked fine, I've adapted it (added a couple of columns) to import different data but I keep getting errors
Warning: Illegal string offset 'Purchase Date' in C:\xampp\htdocs\assets\csv\csvimport.php on line 116
Warning: Illegal string offset 'Comments' in C:\xampp\htdocs\assets\csv\csvimport.php on line 117
Warning: Illegal string offset 'Location' in C:\xampp\htdocs\assets\csv\csvimport.php on line 118
Warning: Illegal string offset 'User' in C:\xampp\htdocs\assets\csv\csvimport.php on line 119
Warning: Illegal string offset 'OldLocation' in C:\xampp\htdocs\assets\csv\csvimport.php on line 120
line 116
$purchase = $mac['Purchase Date'];
I've echo'd each key before and that is working fine but when I try to add each key to a variable ready for to import in to the database I get the warnings.
my code for the relevant part is
echo "<br /><br /><strong>Name:</strong> ".$mac['Name']."<br />";
echo "<strong>model:</strong> ".$mac['Model']."<br />";
echo "<strong>serial:</strong> ".$mac['Serial']."<br />";
echo "<strong>mac:</strong> ".$mac['Mac']."<br />";
echo "<strong>purchase:</strong> ".$mac['Purchase Date']."<br />";
echo "<strong>comments:</strong> ".$mac['Comments']."<br />";
echo "<strong>location:</strong> ".$mac['Location']."<br />";
echo "<strong>user:</strong> ".$mac['User']."<br />";
echo "<strong>oldlocation:</strong> ".$mac['OldLocation']."<br />";
$name = makeuserfriendly($mac['Name']);
$model = makeuserfriendly($mac['Model']);
$serial = makeuserfriendly($mac['Serial']);
$mac = makeuserfriendly($mac['Mac']);
$purchase = $mac['Purchase Date'];
$comments = makeuserfriendly($mac['Comments']);
$location = makeuserfriendly($mac['Location']);
$user = makeuserfriendly($mac['User']);
$oldlocation = makeuserfriendly($mac['OldLocation']);
When I print_r $mac I get this
Array ( [0] => test [1] => 20 [2] => w89364aa66h [3] => test [4] => 10/09/2009 [5] => Media Studies [6] => test [7] => test [8] => test [Name] => test [Model] => 20 [Serial] => w89364aa66h [Mac] => test [Purchase Date] => 10/09/2009 [Comments] => Media Studies [Location] => test [User] => test [OldLocation] => test )
Does anyone have any ideas whey it stops working half way through assigning each key to a variable. I have tried using key values instead of names but I still get the same warnings.
Thanks
Kevin