-1

Please note that this is not normal syntax error its working offline and not online..

I have below code in PHP which is working perfectly online

for($i=0; $i<$colCount;$i++){
    $keys = array_keys($cols)[$i];
    $values = array_values($cols[$i]);
    $stmt->bindValue(":".$keys, $values);
}

But when i uploaded the same thing to online i got below error..??

PHP Parse error:  syntax error, unexpected '[', expecting ',' or ';' in XXXXXXXXX on line 183

What can be the issue..??

Dhawal Mhatre
  • 435
  • 2
  • 8
  • 28

1 Answers1

1

This issue may have caused due to PHP version. You need to be running PHP 5.4+ to use shorthand arrays You can try

for($i=0; $i<$colCount;$i++){
    $key = array_keys($cols);
    $keys = $key[$i];
    $values = array_values($cols[$i]);
    $stmt->bindValue(":".$keys, $values);
}
Ajay
  • 235
  • 2
  • 8