Jump to content

Parse error: syntax error, unexpected '['


ebolt007

Recommended Posts

I'm getting a parse error on line 302:

Parse error: syntax error, unexpected '[' in /home/bhharley/public_html/newsite2/calendar/admin.php  on line 302

 

Line 302 is

$day = getdatefromcalendarformat( $_REQUEST['dt'] )[2];

 

If I take out the [2] it works, but the calendar I'm working on breaks of course. How do I fix this?

Link to comment
Share on other sites

Unfortunately, you can't access members of an array returned from a function like that.

 

$day = getdatefromcalendarformat( $_REQUEST['dt'] );
$day = $day[2];

Link to comment
Share on other sites

Great thanks, that fixed that but now I have one more error.

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/bhharley/public_html/newsite2/calendar/admin.php on line 575

 

here's the line 

$_REQUEST['dt'] = strtotime( $year."-".$month * 1."-".$day );

 

Thanks in advance.

Link to comment
Share on other sites

If you wanted to do that you'd need to put the math inside of parenthesis:

 

$_REQUEST['dt'] = strtotime( $year."-".($month * 1)."-".$day );

 

But what's the point of multiplying $month by 1 anyway?

Link to comment
Share on other sites

Awesome thanks, that fixed it as well.

 

Not sure why it's multiplying by one, I'm decoding it to figure that out. It's a calendar I downloaded and am trying to figure out, was just stuck on those 2 areas. Thanks a lot.  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.