I want to fill MySQL table with 2-dim array data:
for($i=0; $i<sizeof($arr); $i++)
{
$query1="INSERT INTO `fsTest` (`id`,`xxx`,`yyy`,`zzz`)
VALUES('$arr[$i][0]','$arr[$i][1]','$arr[$i][2]','$arr[$i][3]');";
$result1=DatabaseConnector::ExecuteQuery($query1);
}
When I check the table ‘fsTest’ I can see just 1 line with the following entries [0] [1] [2] [3].
How to solve this issue?
UPDATE: Another thing is that I use $arr[$i][] = $val; to populate the array. var_dump($arr) returns Arrayint(0).
You need curly braces around your variable names:
Otherwise, the parser is lazy and will find
$arr[$i]first and attempt to insert that value as a string, instead of$arr[$i][0].A quick example demonstrates this behavior: