Jump to content

Confusing Parse error


lostprophetpunk

Recommended Posts

Everytime I test my page, I seem to get a parse error, in which I have tried to identify the problem but I am stumped as to what it is.

 

This is the error...

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\drew\film.php on line 21

 

The php code (lines 21-24 relevant to the error) are below...

<?php if($flm == "73d0" || $flm == "9017" || $flm == "c3a2") {$pass = 1}else {$pass = 2} ?>
<?php if ($pass != 1) { ?><meta http-equiv="refresh" content="0;url=/drew/"><?php }else { ?>

<?php echo "hello"; } ?>

 

If you could help, thanks in advance.

Link to comment
Share on other sites

PHP statements have to be ended with a semicolon, so in this line:

 

<?php if($flm == "73d0" || $flm == "9017" || $flm == "c3a2") {$pass = 1}else {$pass = 2} ?>

 

change it to

{$pass=1;} else {$pass=2;}

 

It may or may not be the issue but it's something I noticed

Link to comment
Share on other sites

I have done that. It is now saving the same thing but on line 22.

 

Hmmm...K, lets take another look shall we?

 

That error usually means you have an extra } or an unescaped one. I don't see anything at first glance, but I'll look deeper. BTW..why do you switch in and out of <?php ?> so much?

Link to comment
Share on other sites

Try this and let me know what happens

 

<?php 
if ($flm == "73d0" || $flm == "9017" || $flm == "c3a2") {
$pass = 1;
} else {
$pass = 2;
}
if ($pass != 1) {
echo '<meta http-equiv="refresh" content="0;url=/drew/">';
} else { 
echo "hello"; 
} 
?>

Link to comment
Share on other sites

LOL so it's just changing the line number. What is currently on line 23? Can you post your current code? it might be coming from right before that line too, so post a few lines before also

Link to comment
Share on other sites

BTW..why do you switch in and out of <?php ?> so much?

 

I've got to ask the same thing. Why are you writing code like that. The following is the equivalent code, written out traditionally (edit: LOL, identical suggestion to what DevilsAdvocate posted above) -

 

<?php
if($flm == "73d0" || $flm == "9017" || $flm == "c3a2")
{
$pass = 1;
} else {
$pass = 2;
}
if($pass != 1)
{
echo '<meta http-equiv="refresh" content="0;url=/drew/">';
} else {
echo "hello";
}
?>

 

Yes it takes a few more lines up in the file, but it also doesn't contain any syntax errors and you can see that it does not because you can see each line of code without all the clutter of the <?php ?> tags.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.