Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

When I run this script on my local server it works just fine. However when I run it on a hostgator server I get this error:

 Parse error: syntax error, unexpected '[' in /home/user/public_html/parsing/parse.php on line 46

Line 46 is this: $rows = [];

Any idea why this could be happening? Thank you. By the way I have only copied up to line 46, there are a few more lines of code than shown here.

share|improve this question
2  
What version of PHP are you using? Short array syntax was added in PHP 5.4.0. – TRiG Aug 29 '14 at 0:12
2  
Change $rows = []; to $rows = array(); – Mic1780 Aug 29 '14 at 0:13
up vote 4 down vote accepted

The new array syntax [] is only available in versions 5.4 and greater.

If you are using a PHP version prior to 5.4 you have to use this syntax to create an empty array

$row = array();
share|improve this answer
    
Did you say 5.4? On cpanel it says this: A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is 4.2.7.1, released on 2014-08-17. – Arjun Singh Aug 29 '14 at 0:15
    
In the PHP manual is says THIS Check what version of PHP is running on your hostgator hosting package – RiggsFolly Aug 29 '14 at 0:16
    
You are right, this solved it. What should I change this line of code to in order to prevent the error? Thanks $row_start = [$file_id, 0, 'NOW()']; – Arjun Singh Aug 29 '14 at 0:18
    
Try $row_start = array($file_id, 0, 'NOW()'); – RiggsFolly Aug 29 '14 at 0:20
    
I would ask your host to upgrade the version of PHP they are using. The current STABLE version of PHP is now PHP5.5.16 and PHP5.6 will be out any day now. – RiggsFolly Aug 29 '14 at 0:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.