Hi Guys,


I'm having difficulties inserting Multidimensional php array into mysql database. Could you please see what am I doing wrong?

PHP Code:
$array = array(
     array(
        
'id' => 1,
        
'firstName' => 'Paul',
        
'surname' => 'Crowe',
        
'age' => 28,
        
'gender' => 'male',
        
'connections' => array(2),
        
'cities' => array('Dublin' => 80'New York' => 100'Paris' => 95'Madrid' => 100'London' => 80'Barcelona' => 100'Moscow' => 20)
    ),
     array(
        
'id' => 2,
        
'firstName' => 'Rob',
        
'surname' => 'Fitz',
        
'age' => 23,
        
'gender' => 'male',
        
'connections' => array(13),
        
'cities' => array('Dublin' => 40'New York' => 100'Paris' => 65'Madrid' => 90)
    ),
     array(
        
'id' => 3,
        
'firstName' => 'Ben',
        
'surname' => "O'Carolan",
        
'age' => null,
        
'gender' => 'male',
        
'connections' => array(2457),
        
'cities' => array('Paris' => 90'Madrid' => 40'London' => 85'Barcelona' => 90'Moscow' => 80)
    ),
     array(
        
'id' => 4,
        
'firstName' => 'Victor',
        
'surname' => '',
        
'age' => 28,
        
'gender' => 'male',
        
'connections' => array(3),
        
'cities' => array('Paris' => 80'Madrid' => 80'London' => 80'Barcelona' => 80'Moscow' => 40)
    ),
     array(
        
'id' => 5,
        
'firstName' => 'Peter',
        
'surname' => 'Mac',
        
'age' => 29,
        
'gender' => 'male',
        
'connections' => array(3611107),
        
'cities' => array('Dublin' => 60'New York' => 100'Paris' => 75)
    ),
);

foreach(
$array as $data){

    
$sql "INSERT INTO people (firstName, surname, age, gender, connections, cities)
    VALUES (
$data[firstName]$datas[surname]$data[age]$data[gender]$data[connections]$data[cities])";