Jump to content

Fatal error in module file : //statsdata.php: syntax error, unexpected '['


Recommended Posts

hi every one,

 

I need help to solv a problem.

 

here it goes,

 

1. I installed 1.6.1.7 version prestashop.

2. when i configure the shop in backoffice, I disabled a standard module which shows a block extra information on frontpage in "Module and services" , see attached files.

 

3. now the backoffice showing , 

 

[PrestaShop] Fatal error in module file :/var/www/vhosts/my root catalog /modules/statsdata/statsdata.php: syntax error, unexpected '['

 

and i am not able to access  "modules and services"  also frontpage showing "page isn’t working"

 

can you give me some advices? 

post-1334331-0-16269000-1478290206_thumb.png

Edited by htrow (see edit history)
Link to comment
Share on other sites

The same error for me, when I try to update a module:

 

[PrestaShop] Fatal error in module file :/var/www/vhosts/xxxxxxx/httpdocs/modules/statsdata/statsdata.php:

syntax error, unexpected '['

 

My info

 

Informazioni sul server Linux #1 SMP Thu Aug 11 09:41:14 MSK 2016 x86_64

Versione software server Apache

Versione di PHP 5.3.29

Limite memoria 128M

Tempo di esecuzione massimo 120

Link to comment
Share on other sites

Hi, i believe that the problem is the new code added in the /modules/statsdata/statsdata.php file.

 

If you go to line 101:

private function getScriptPlugins($params)
    {
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);

            if (Configuration::get('PS_STATSDATA_PLUGINS')) {
                if (_PS_VERSION_ >= 1.7) {
                    $this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', ['position' => 'bottom', 'priority' => 150]);
                } else {
                    $this->context->controller->addJS($this->_path.'js/plugindetect.js');
                }
                ..............

If u are not using PS 1.7, u can comment the line

/* $this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', ['position' => 'bottom', 'priority' => 150]); */
                

and will work! :D

 

If u are using PS 1.7... you will need to check that line and modify it.. There is a little problem with syntax on that line that need to be solved.

  • Like 3
Link to comment
Share on other sites

Hi, i believe that the problem is the new code added in the /modules/statsdata/statsdata.php file.

 

If you go to line 101:

private function getScriptPlugins($params)
    {
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);

            if (Configuration::get('PS_STATSDATA_PLUGINS')) {
                if (_PS_VERSION_ >= 1.7) {
                    $this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', ['position' => 'bottom', 'priority' => 150]);
                } else {
                    $this->context->controller->addJS($this->_path.'js/plugindetect.js');
                }
                ..............

If u are not using PS 1.7, u can comment the line

/* $this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', ['position' => 'bottom', 'priority' => 150]); */
                

and will work! :D

 

If u are using PS 1.7... you will need to check that line and modify it.. There is a little problem with syntax on that line that need to be solved.

Great piribipipi! 1.6.7, line commented and it works. Thx a lot.

  • Like 1
Link to comment
Share on other sites

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));
Edited by razaro (see edit history)
  • Like 4
Link to comment
Share on other sites

 

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));

 

@razaro: You're a lifesaver! I just added the 2nd closing bracket @ EOL and it works like a charm.

  • Like 1
Link to comment
Share on other sites

 

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));

TY SO MUCH!!!

 

btw, Can someone tell me how to upgrade my PHP version? i use the 5.3.27 version and now I have to change to version 5.4 but when I upgrade from cpanel gives me another "fatal error"

I appreciate the help

Link to comment
Share on other sites

 

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));

Thanks - it works, but am I going blind? Where's the opening bracket for that closing bracket?

  • Like 1
Link to comment
Share on other sites

Hello Everybody, thank you in advanced. I AM GOING CRAZY HERE!!!

 

I was adding products to my new store, and suddenly it stopped working. In my store front I get this message:

 

page isn´t working.

drakoslab.com is currently unable to handle this request.

500

 

in my backoffice, I cant access the modules & Services, and it shows this message:

 

[PrestaShop] Fatal error in module file :/home/drakos/public_html/tienda/modules/statsdata/statsdata.php:
syntax error, unexpected '['

 

As far I can tell, I can access all other areas of my backoffice.

 

 

How do I fix this??

 

How do I get to where I need to edit line 101?

how do I update my PHP version? (i´m using PS version 1.6.1.7)

 

I´m a Newby, and not much of a computer person, please help me as if you were teaching a kid. thank you!!!

Edited by DiegoMarquina (see edit history)
Link to comment
Share on other sites

Yes, in the CHECK YOUR CONFIGURATION Box. it reads:

 

REQUIRED PARAMETERS: OK

 

OPTIONAL PARAMETERS: PLEASE FIX THE FOLLOWING ERROR(S)

-YOU ARE USING PHP 5.3.29 VERSION. SONN, THE LATEST PHP VERSION SUPPORTED BY PRESTASHOP WILL BE PHP 5.4 TO MAKE SURE YOU´RE READY FOR THE FUTURE, WE RECOMMEND YOU TO UBREADE TO PHP 5.4 NOW!

-ALLOW THE PHP FOPEN()FUNCTION ON YOUR SERVER.

 

I do not know what they are talking about :(

thank you for your help.

Link to comment
Share on other sites

thank you, I just updated de PHP version to 5.5.

the store front changed the error message for:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Link to comment
Share on other sites

 

Maybe  like this

$this->context->controller->registerJavascript(
    'modules-plugindetect',
    'modules/'.$this->name.'/js/plugindetect.js',
    array('position' => 'bottom', 'priority' => 150)
);

Duh! Thanks - evidently I *am* going blind. Not so much simply "adding a closing bracket" as "changing the array format," though - which makes sense.

Edited by PeteW (see edit history)
Link to comment
Share on other sites

hi every one,

 

I need help to solv a problem.

 

here it goes,

 

1. I installed 1.6.1.7 version prestashop.

2. when i configure the shop in backoffice, I disabled a standard module which shows a block extra information on frontpage in "Module and services" , see attached files.

 

3. now the backoffice showing , 

 

[PrestaShop] Fatal error in module file :/var/www/vhosts/my root catalog /modules/statsdata/statsdata.php: syntax error, unexpected '['

 

and i am not able to access  "modules and services"  also frontpage showing "page isn’t working"

 

can you give me some advices? 

Don't comment the line. Replace opening '[' with array. So full line will read....."$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));"

Link to comment
Share on other sites

 

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));

Perfect!!!!

Link to comment
Share on other sites

I'm having a different issue with my module/statsdata/statsdata.php file, this time at line 108. The error I'm getting is: Parse error: syntax error, unexpected '[' on line 108. Any help would be appreciated!

 

// Record the guest path then increment the visit counter of the page
$token_array = Connection::setPageConnection($params['cookie']);
ConnectionsSource::logHttpReferer();
if (Configuration::get('PS_STATSDATA_PAGESVIEWS'))
Page::setPageViewed($token_array['id_page']);
 
if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
{
// Ajax request sending the time spend on the page
$token = sha1($token_array['id_connections'].$token_array['id_page'].$token_array['time_start']._COOKIE_KEY_);
$html .= '
<script type="text/javascript">
var time_start;
$(window).load(
function() {
time_start = new Date();
}
);
$(window).unload(
function() {
var time_end = new Date();
var pagetime = new Object;
pagetime.type = "pagetime";
pagetime.id_connections = "'.(int)$token_array['id_connections'].'";
pagetime.id_page = "'.(int)$token_array['id_page'].'";
pagetime.time_start = "'.$token_array['time_start'].'";
pagetime.token = "'.$token.'";
pagetime.time = time_end-time_start;
}
);
</script>';
}
 
 
Link to comment
Share on other sites

 

 

True if you do not use 1.7 commenting line will get job done.

But to explain, issue is in PHP version 5.3. It is bit older so it shows error on that line.

To make it work and not commenting try using this code instead.

$this->context->controller->registerJavascript('modules-plugindetect', 'modules/'.$this->name.'/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));

Thanks - it works, but am I going blind? Where's the opening bracket for that closing bracket?

 

Excellent ... thanks !!!

Link to comment
Share on other sites

Hi! I´m using Prestashop 1.7, when i try to enter in the "menú" module to configure the show categories, appear this error:

[PrestaShop] Fatal error in module file :/var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/app/bootstrap.php.cache:
Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Catchable Fatal Error: Argument 2 passed to PrestaShopBundle\Translation\TranslatorComponent::trans() must be of the type array, integer given, called in /var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/config/smartyadmin.config.inc.php on line 114 and defined' in /var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/src/PrestaShopBundle/Translation/PrestaShopTranslatorTrait.php:35 Stack trace: #0 /var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/src/PrestaShopBundle/Translation/PrestaShopTranslatorTrait.php(35): Symfony\Component\Debug\ErrorHandler->handleError(4096, 'Argument 2 pass...', '/var/www/vhosts...', 35, Array) #1 /var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/config/smartyadmin.config.inc.php(114): PrestaShopBundle\Translation\TranslatorComponent->trans('There are %d wa...', 2, NULL) #2 /var/www/vhosts/26/190975/webspace/httpdocs/MYDOMAIN.com/app/cache/prod/smarty/compile/8c/85/6b
Link to comment
Share on other sites

  • 2 weeks later...

 

Maybe  like this

$this->context->controller->registerJavascript(
    'modules-plugindetect',
    'modules/'.$this->name.'/js/plugindetect.js',
    array('position' => 'bottom', 'priority' => 150)
);

@razaro - Greetings! Where does one put this code in the statsdata.php document? Which line? Thanks!

Edited by ArtistToonz (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Hi, I have a similar error

Parse error: syntax error, unexpected T_STRING in /web/htdocs/www.miosito.it/home/modules/statsdata/statsdata.php on line 234

 

Informazioni sul server Linux #1 SMP Fri Nov 18 19:25:05 UTC 2016 x86_64

Versione software server Apache

Versione di PHP 5.3.29

Limite memoria 128M

Tempo di esecuzione massimo 120

Versione di PrestaShop 1.6.0.9

I 'm not an expert,  you can help me to resolve the problem and to tell me where I must intervene?

Thanks in advance

Link to comment
Share on other sites

  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...