Error
A PHP parse error returns, citing an "unexpected $". Because this is a parse error, the PHP script does not run to any extent.
Solution
This error almost always results in a missing bracket somewhere. Check your code carefully for missing brackets. Using a PHP IDE can be useful for checking brackets that are not closed. Brackets that span multiple PHP sections can be the trickiest to miss. For instance:
1 2 3 4 5 6 7 8 9 10 |
<?php $x = 3; if($x == 3){ ?> <a href="http://www.thetechrepo.com">The Tech Repo rules!</a> <?php } //CLOSING BRACKET -- EASY TO MISS ?> |
It can be easy to forget the trailing bracket when html is placed in between two PHP brackets. Fix the bracket problem, and this parse error should go away.




