lostprophetpunk Posted August 6, 2010 Share Posted August 6, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/ Share on other sites More sharing options...
TOA Posted August 6, 2010 Share Posted August 6, 2010 Try adding semicolons to $pass definitions and let us know what happens Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095969 Share on other sites More sharing options...
lostprophetpunk Posted August 6, 2010 Author Share Posted August 6, 2010 Try adding semicolons to $pass definitions and let us know what happens You just lost me there...:S Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095971 Share on other sites More sharing options...
TOA Posted August 6, 2010 Share Posted August 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095973 Share on other sites More sharing options...
lostprophetpunk Posted August 6, 2010 Author Share Posted August 6, 2010 I have done that. It is now saving the same thing but on line 22. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095975 Share on other sites More sharing options...
TOA Posted August 6, 2010 Share Posted August 6, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095976 Share on other sites More sharing options...
TOA Posted August 6, 2010 Share Posted August 6, 2010 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095977 Share on other sites More sharing options...
lostprophetpunk Posted August 6, 2010 Author Share Posted August 6, 2010 I have tried it. It brings it up now with line 23. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095978 Share on other sites More sharing options...
TOA Posted August 6, 2010 Share Posted August 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095979 Share on other sites More sharing options...
PFMaBiSmAd Posted August 6, 2010 Share Posted August 6, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095981 Share on other sites More sharing options...
lostprophetpunk Posted August 6, 2010 Author Share Posted August 6, 2010 The reason I do go in and out of php tags is because of the html code I will be creating later, as I don't like to write html code in php. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1095983 Share on other sites More sharing options...
PFMaBiSmAd Posted August 7, 2010 Share Posted August 7, 2010 Yes, but if you cannot even find your own simple php syntax errors because you cannot see them, you are not gaining anything by writing code like that. Quote Link to comment https://forums.phpfreaks.com/topic/209976-confusing-parse-error/#findComment-1096356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.