Parse error: syntax error, unexpected T_STRING in ... functions.php

Discussion in 'PHP' started by nadhari, Jun 3, 2010.

  1. #1
    I am trying to install a new theme "fashionable" by themebell and having errors installing the theme.
    The particular section with the error is

    add_shortcode('vimeo', 'insertVimeo');
    function insertVimeo($attr) {
        // set dimensions
        $width = 520;
        $height = 400;
        // get the url
        $src = $attr['src'];
        // get the video ID
        $video_code = substr($src,strrpos($src,'/')+1,strlen($src));
        // set the movie params value
        $src = 'http://vimeo.com/moogaloop.swf?clip_id='.$video_code.'&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1';
        // set the object
        $video = '<script type="text/javascript">
    AC_AX_RunContent( ''width','\'.$width.\'','height','\'.$height.\'','src','\'.$src.\'','wmode','transparent','type','application/x-shockwave-flash','allowfullscreen','true','allowscriptaccess','always','movie','\'.$src.\''' ); //end AC code
    </script><noscript><object width="'.$width.'" height="'.$height.'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'.$src.'" /><embed src="'.$src.'"  wmode="transparent" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'.$width.'" height="'.$height.'"></embed></object></noscript>';
        // display the object
        return $video;    
    }
    PHP:
    I get the error in thr AC_AX_Run... line which is line
    Removing this section completely gives me 10+ errors compared to the single error now. I am new to PhP and would appreciate it if someone could guide me through this
     
    nadhari, Jun 3, 2010 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,901
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    try it like this
    add_shortcode('vimeo', 'insertVimeo');
    function insertVimeo($attr) {
        // set dimensions
        $width = 520;
        $height = 400;
        // get the url
        $src = $attr['src'];
        // get the video ID
        $video_code = substr($src,strrpos($src,'/')+1,strlen($src));
        // set the movie params value
        $src = 'http://vimeo.com/moogaloop.swf?clip_id='.$video_code.'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1';
        // set the object
        $video = "<script type='text/javascript'>
    AC_AX_RunContent( 'width','{$width}','height','{$height}','src','{$src}','wmode','transparent','type','application/x-shockwave-flash','allowfullscreen','true','allowscriptaccess','always','movie','{$src}' ); //end AC code
    </script>
        <noscript>
        	<object width='{$width}' height='{$height}'><param name='allowfullscreen' value='true' />
        		<param name='allowscriptaccess' value='always' />
        		<param name='movie' value='{$src}' />
        		<embed src='{$src}'  wmode='transparent' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='{$width}' height='{$height}'></embed>
        	</object>
        </noscript>";
        // display the object
        return $video;    
    }
    PHP:
    but really, it just seems that the escaping of the single quotes got mangled. This version should be safer.
     
    sarahk, Jun 4, 2010 IP