Parse Error unexpected 'if'

Hello can anyone help me figure out where the problem is?

The error that I’m receiving is Parse error: syntax error, unexpected ‘if’ (T_IF) in your code on line 25

<?php
for($i=$begin; $result != 0 && $i < $end; $i++)
{
        $music_file = ex_tag($result[$i], "<music_file>");
        $player = "player".$i;


        if ($music_file != "")
        {
                $sound_file_url =       "music/".$music_file;
                $sound_file = 'onclick="play(\'music/'.$music_file.'\',\''.$player.'\')"';
        }
        else
        {
                $sound_file_url = "";
                $sound_file = "";
        }

        ?>
<div class="pf_pad_box_long">
<div class="pf_long_img_new"><!--<img
        src="images/<?php echo ex_tag($result[$i], "<image>"); ?>" alt=""
        width="230" height="172" class="imgcenter" />--></div>
<div class="pf_long_text_new">
<h2><a href="#"><?php echo ex_tag($result[$i], "<subject>"); ?></a></h2>
<p class="pf-text"><?php echo ex_tag($result[$i], "<content>"); ?></p>
<div class="pf-button" id="<?phpphp //echo $player; ?>"><?phpphp
if ($sound_file_url != "" )
{
        if ($safari == 0)
        {
                ?> <script type="text/javascript">document.write(showPLayer_song("<?phpphp echo $sound_file_url; ?>"));</script>
                <?phpphp
        }
        else
        {
                ?> <object height="50" width="200">
        <param name="kioskmode" value="true">
        <param name="src" value="<?phpphp echo $sound_file_url; ?>">
        <param name="autoplay" value="false">
        <param name="controller" value="true"><embed height="50"
                src="<?phpphp echo $sound_file_url; ?>" type="video/quicktime"
                width="200" controller="true" autoplay="false" kioskmode="true">

</object> <?phpphp
        }
}
?></div>
<div></div>
</div>
</div>
<?php

You never close the for loop.

How would I go about closing the for loop?

By adding the missing curly bracket

Where would I place the curly bracket? To end the loop?

Are you trying to learn?

Any advanced editor (Notepad++ even) will quickly highlight the missing closing bracket…
Also…

What is this junk?

<?phpphp?

And at the end… you are NOT closing your PHP tag… your opening a new one?

Where did you get this code from?

<?php
for($i=$begin; $result != 0 && $i < $end; $i++){
    $music_file = ex_tag($result[$i], "<music_file>");
    $player = "player".$i;

    if ($music_file != ""){
            $sound_file_url =       "music/".$music_file;
            $sound_file = 'onclick="play(\'music/'.$music_file.'\',\''.$player.'\')"';
    }
    else{
            $sound_file_url = "";
            $sound_file = "";
    }

	?>
	<div class="pf_pad_box_long">
		<div class="pf_long_img_new">
			<!--<img src="images/<?php// echo ex_tag($result[$i], "<image>"); ?>" alt="" width="230" height="172" class="imgcenter" />-->
		</div>

		<div class="pf_long_text_new">
			<h2><a href="#"><?php echo ex_tag($result[$i], "<subject>"); ?></a></h2>
			
			<p class="pf-text"><?php echo ex_tag($result[$i], "<content>"); ?></p>
			
			<div class="pf-button" id="<?phpphp //echo $player; ?>">
			<?php
				if ($sound_file_url != "" ){
					if ($safari == 0){
						?> 
						<script type="text/javascript">document.write(showPLayer_song("<?phpphp echo $sound_file_url; ?>"));</script>
						<?php
					}else{
						?> 
						<object height="50" width="200">
							<param name="kioskmode" value="true">
							<param name="src" value="<?phpphp echo $sound_file_url; ?>">
							<param name="autoplay" value="false">
							<param name="controller" value="true"><embed height="50" src="<?php echo $sound_file_url; ?>" type="video/quicktime" width="200" controller="true" autoplay="false" kioskmode="true">

						</object> 
						<?php
					}
				}
				?>
			</div>
			<div></div>
		</div>
	</div>
	
	<?php
}  //you didnt close for loop as stated
?>

I’m still receiving Parse error: syntax error, unexpected ‘if’. My website isn’t reachable

Post YOUR code that you are using then…

Did you do the clean up suggested above?

Sponsor our Newsletter | Privacy Policy | Terms of Service