robotturtle
robotturtle

Reputation: 71

Echo mix of HTML and PHP giving an error

I'm trying to echo this long statement, tried looking at other answers here, nothing is fixing it.

Error: 
Parse error: parse error, expecting `','' or `';'' 
Errors parsing -

.

<?php 

$videoEmbed = get_post_meta( get_the_id(), 'ctslider_videoembedcode', true ); 
$postThumb = the_post_thumbnail();


echo '<div onclick="thevid=document.getElementById('thevideo'); thevid.style.display='block'; this.style.display='none'"><img src="'.echo $postThumb.'" style="cursor:pointer" /></div><div id="thevideo" style="display:none">"'.echo $videoEmbed.'"</div>';?>

Upvotes: 0

Views: 535

Answers (4)

user3084091
user3084091

Reputation: 11

You have to add <?php ?> around any php commands you are typing. try <?php echo "whatever you want here"?>

Upvotes: 0

Krish R
Krish R

Reputation: 22711

Can you try this,

echo '<div onclick="thevid=document.getElementById(\'thevideo\'); thevid.style.display=\'block\'; this.style.display=\'none\'">
         <img src="'.$postThumb.'" style="cursor:pointer" />
      </div>
      <div id="thevideo" style="display:none">"'.$videoEmbed.'"</div>';

Upvotes: 0

Yoann Augen
Yoann Augen

Reputation: 2036

Do you realy need to echo a div? Can't you do that :

<div onclick="thevid=document.getElementById('thevideo'); thevid.style.display='block'; this.style.display='none'"> 
    <img src="<?php echo $postThumb ?>" style="cursor:pointer" />
</div>
<div id="thevideo" style="display:none">
    <?php echo $videoEmbed ?>
</div>

Upvotes: 0

Igoooor
Igoooor

Reputation: 407

You have to escape your ' So it gives:

echo '<div onclick="thevid=document.getElementById(\'thevideo\'); thevid.style.display=\'block\'; this.style.display=\'none\'"><img src="'.$postThumb.'" style="cursor:pointer" /></div><div id="thevideo" style="display:none">"'.$videoEmbed.'"</div>';

And you don't need echo inside the first echo

Upvotes: 6

Related Questions