Conditional statement with three condition

You’re missing } before elseif:

<?php if (is_page ('20')){?>
print this
<?php } elseif (is_page ('50')){?>
then print this
<?php } else { ?>
print this
<?php } ?>

Remove the PHP tags and you’ll see why:

if ( is_page( '20' ) ) {

elseif ( is_page( '50' ) ) {

} else {

}