Parse error: syntax error, unexpected T_CONSTANT

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bobbf1
Forum Newbie
Posts: 8
Joined: Wed Nov 23, 2011 3:30 pm

Parse error: syntax error, unexpected T_CONSTANT

Post by bobbf1 »

Hi,

I have an array below. The individual part of the code below (starting with 'javascriptcode') is triggering a php error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')'

I understand the error is because " or ' are not escaped properly. I was able to remove the error from the other lines of code. For some reason, I cannot get this error for the bolded line of code to go away though.

Code: Select all

'javascriptcode' => 'setpage(\'thumb' '.$thumbnumber.'\', \''.get_permalink($wppost->ID).'\', \''.get_video_thumbnail($wppost->ID).'\')'

Code: Select all

$data = array(
						'title' => '<a class="one" href="'.get_permalink($wppost->ID).'" title="'. $title_attr .'" onMouseOver="setpage(\'thumb' .$thumbnumber.'\', \''.get_permalink($wppost->ID).'\', \''.get_video_thumbnail($wppost->ID).'\')"><span class="wpp-post-title">'. $tit .'</span></a>',
						'summary' => $post_content,
						'stats' => $stats,
						'img' => $thumb,
						'id' => $wppost->ID,
						'posttime' =>  '<span class="wpp-post-time"> (\''.get_field('video_time', $wppost->ID).'\')</span>'
						'javascriptcode' => 'setpage(\'thumb' '.$thumbnumber.'\', \''.get_permalink($wppost->ID).'\', \''.get_video_thumbnail($wppost->ID).'\')'
					);	
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Parse error: syntax error, unexpected T_CONSTANT

Post by maxx99 »

Nice mess you've got here :)

Try: (missing comma on after postime, one ' too much in javascriptcode

Code: Select all

<?php

$data = array( 'title' => '<a class="one" href="'.get_permalink($wppost->ID).'" title="'. $title_attr .'" onMouseOver="setpage(\'thumb' .$thumbnumber.'\', \''.get_permalink($wppost->ID).'\', \''.get_video_thumbnail($wppost->ID).'\')"><span class="wpp-post-title">'. $tit .'</span></a>',
                                                 'summary' => $post_content,
                                                 'stats' => $stats,
                                                 'img' => $thumb,
                                                 'id' => $wppost->ID,
                                                 'posttime' =>  '<span class="wpp-post-time"> (\''.get_field('video_time', $wppost->ID).'\')</span>',
                                                 'javascriptcode' => 'setpage(\'thumb' .$thumbnumber.'\', \''.get_permalink($wppost->ID).'\', \''.get_video_thumbnail($wppost->ID).'\')'
                                         );  
?>
bobbf1
Forum Newbie
Posts: 8
Joined: Wed Nov 23, 2011 3:30 pm

Re: Parse error: syntax error, unexpected T_CONSTANT

Post by bobbf1 »

Thanks that worked!

It is quite a mess. I am editing someone else's wordpress plugin and my eyes are glazing over :)
Post Reply