1

guys i want to get from database prestashop category info with module and i use sql query but if i try to assign foreach array prestashop retun me a error code : Parse error: syntax error, unexpected 'return' (T_RETURN)

This is my code

    public function hookDisplayHome()
    {
    $getcategory = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'category_lang`');
    $cattegoryinfo=array();
    foreach($getcategory as $getcategoryinfo){
        $cattegoryinfo[] = array(
         "name" => $getcategoryinfo['name']
         );
    }
         $this->context->smarty->assign('categories', $cattegoryinfo);
         return $this->display(__FILE__,'views/showcategory.tpl');
}
Besa Besa
  • 11
  • 1

2 Answers2

1

I test your codes and I find a special character after ";" on this line:

$this->context->smarty->assign('categories', $cattegoryinfo);

Remove it and try again

Mahdi Shad
  • 1,427
  • 1
  • 14
  • 23
0

There is an  character after the semicolon.

maybe this can help you: How to avoid echoing character 65279 in php? (This question also relates to Javascript xmlhttp.responseText (ajax))

Alberto Moro
  • 1,014
  • 11
  • 22