$d = $_SESSION['post'];
unset($_SESSION['post']);
foreach($d as $k => $v) {
\sys\CDatabase::query('UPDATE sportart SET
name = "?name",
reihenfolge = "?reihenfolge"
WHERE sportart_id = "?id"',array(
'name'=>$v['name'],
'reihenfolge'=>$v['reihenfolge'],
'id'=>$k
),'none');
}
need fast help on this code pls, every time i try it an error occurs which says
Illegal string offset 'name'
The array $d
contains values of mixed types. One of the values is a string (a kind of model name, according to your comment: "model" => "models\BackendSportartenAendern"
).
Thus the error: you're trying to use the string as if it were a (sub-)array.
One easy way to fix the code is to modify your loop so that non-array values are skipped:
foreach($d as $k => $v) {
if (!is_array($v)) {
continue;
}
\sys\CDatabase::query(...);
}