So i have this code 32 <body>{{ga_code}}<div class="root"><div class="vbox wb_container" id="wb_header"> 33 34 <div id="wb_element_instance79" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div></div> 35 <div class="vbox wb_container" id="wb_main"> 36 <?php 37 if($_SESSION['logged_in']) 38 print { 49 <div id="wb_element_instance80" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div><div id="wb_element_instance83" class="wb_element" style=" overflow: hidden;">< 40 <iframe src="https://docs.google.com/spreadsheets/d/1zkxOxRwqhGstemnqFAPrUVrAGtbE7JHAQgxemcqOcHY/edit#gid=0" width="100%" height="4000" frameborder="0" scrolling="yes"></iframe> 41 } 42</div><div id="wb_element_instance84" class="wb_element" style="width: 100%;"> and this is the error: Parse error: syntax error, unexpected '{' in /home/a6634782/public_html/zyro/1.php on line 36 line 36 is still in HTML, could somebody explain to me what i am doing wrong?
Remove the print before the { on line 38? And please, for the love of god, learn how to use the code-tags to wrap code.
<body>{{ga_code}}<div class="root"><div class="vbox wb_container" id="wb_header"> <div id="wb_element_instance79" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div></div> <div class="vbox wb_container" id="wb_main"> <?php if($_SESSION['logged_in']) { <div id="wb_element_instance80" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div><div id="wb_element_instance83" class="wb_element" style=" overflow: hidden;">< <iframe src="https://docs.google.com/spreadsheets/d/1zkxOxRwqhGstemnqFAPrUVrAGtbE7JHAQgxemcqOcHY/edit#gid=0" width="100%" height="4000" frameborder="0" scrolling="yes"></iframe> } </div><div id="wb_element_instance84" class="wb_element" style="width: 100%;"> Code (markup): Parse error: syntax error, unexpected '<' in /home/a6634782/public_html/zyro/1.php on line 37 line 1=32, dont know how to fix this, line 11=42 thanks for the answer, it gave me a new error though (and i got the tags for you ^^)
This is a smarty template or something? If so, I don't think you can have pure PHP in them. You need to use something particular to allow for PHP code in template files.
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Planning - Civilization V</title> <base href="{{base_url}}" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <meta name="generator" content="Zyro - Website Builder" /> <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> <script src="js/main.js" type="text/javascript"></script> <link href="css/site.css?v=1.0.13" rel="stylesheet" type="text/css" /> <link href="css/common.css?ts=1443213817" rel="stylesheet" type="text/css" /> <link href="css/1.css?ts=1443213817" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="http://civilization5.host56.com/gallery/icon_civilization5-ts1442050177.png" type="image/png" /> <script type="text/javascript">var currLang = '';</script> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body>{{ga_code}}<div class="root"><div class="vbox wb_container" id="wb_header"> <div id="wb_element_instance79" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div></div> <div class="vbox wb_container" id="wb_main"> <?php if($_SESSION['logged_in']) { <div id="wb_element_instance80" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div><div id="wb_element_instance83" class="wb_element" style=" overflow: hidden;">< <iframe src="https://docs.google.com/spreadsheets/d/1zkxOxRwqhGstemnqFAPrUVrAGtbE7JHAQgxemcqOcHY/edit#gid=0" width="100%" height="4000" frameborder="0" scrolling="yes"></iframe> } </div><div id="wb_element_instance84" class="wb_element" style="width: 100%;"> ?> <?php global $show_comments; if (isset($show_comments) && $show_comments) { renderComments(1); ?> <script type="text/javascript"> $(function() { var block = $("#wb_element_instance84"); var comments = block.children(".wb_comments").eq(0); var contentBlock = $("#wb_main"); contentBlock.height(contentBlock.height() + comments.height()); }); </script> <?php } else { ?> <script type="text/javascript"> $(function() { $("#wb_element_instance84").hide(); }); </script> <?php } ?> </div></div> <div class="vbox wb_container" id="wb_footer" style="height: 114px;"> <div id="wb_element_instance78" class="wb_element"><a class="btn btn-default btn-collapser"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><ul class="hmenu"><li><a href="Home/" target="_self" title="Home">Home</a></li><li class="active"><a href="Planning/" target="_self" title="Planning">Planning</a></li><li><a href="ScoreBoard/" target="_self" title="ScoreBoard">ScoreBoard</a></li><li><a href="Violation/" target="_self" title="Violation">Violation</a></li><li><a href="Contact/" target="_self" title="Contact">Contact</a></li><li><a href="Players/" target="_self" title="Players">Players</a></li><li><a href="Login/" target="_self" title="Login">Login</a></li><li><a href="Login-Required/" target="_self" title="Login Required">Login Required</a></li></ul><script type="text/javascript"> (function() { var isOpen = false, elem = $('#wb_element_instance78'), btn = elem.children('.btn-collapser').eq(0); btn.on('click', function() { if (elem.hasClass('collapse-expanded')) { isOpen = false; elem.removeClass('collapse-expanded'); } else { isOpen = true; elem.addClass('collapse-expanded'); } }); elem.find('ul').each(function() { var ul = $(this); if (ul.parent('li').length > 0) { ul.parent('li').eq(0).children('a').on('click', function() { if (!isOpen) return true; if (ul.css('display') !== 'block') ul.css({display: 'block'}); else ul.css({display: ''}); return false; }); } }); })(); </script></div><div id="wb_element_instance81" class="wb_element" style=" line-height: normal;"><p class="wb-stl-footer">© 2015 <a href="http://civilization5.host56.com">civilization5.host56.com</a></p></div><div id="wb_element_instance82" class="wb_element"><div class="wb-stl-footer" style="white-space: nowrap;">Member of <i class="icon-wb-logo"></i><a href="http://zyro.com/examples/" target="_blank" title="Zyro - Website Builder">Zyro</a></div><script type="text/javascript"> var _siteProBadge = _siteProBadge || []; _siteProBadge.push({hash: "1b73f084f0336c5299e27cb60719c633", cont: "wb_element_instance82"}); (function() { var script = document.createElement("script"); script.type = "text/javascript"; script.async = true; script.src = "http://zyro.com/examples/getjs/"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(script, s); })(); </script></div><div id="wb_element_instance85" class="wb_element" style="text-align: center; width: 100%;"><div class="wb_footer"></div><script type="text/javascript"> $(function() { var footer = $(".wb_footer"); var html = (footer.html() + "").replace(/^\s+|\s+$/g, ""); if (!html) { footer.parent().remove(); footer = $("#wb_footer"); footer.height(194); } }); </script></div></div><div class="wb_sbg"></div></div></body> </html> Code (markup): this is the entire code, im trying to learn php so i dont know really
through out the file there are more <?php ?> tags in there, more working php, im new to php, so i might just be a massive derp, but i need to get this working, as i have embedded a spreadsheet in there, but we dont want people to mess it up :/
Ah, maybe I read it wrong. It's not the <PHP tag that triggers the error, it's the first <div after the {. You can't have unescaped html within PHP code. Either echo the html or jump out of PHP again (add a ?> after the first {) and wrap the ending } in PHP tags as well
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Planning - Civilization V</title> <base href="{{base_url}}" /> <meta name="viewport" content="width=992" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <meta name="generator" content="Zyro - Website Builder" /> <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> <script src="js/main.js" type="text/javascript"></script> <link href="css/site.css?v=1.0.13" rel="stylesheet" type="text/css" /> <link href="css/common.css?ts=1443268736" rel="stylesheet" type="text/css" /> <link href="css/1.css?ts=1443268736" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="http://civilization5.host56.com/gallery/icon_civilization5-ts1442050177.png" type="image/png" /> <script type="text/javascript">var currLang = '';</script> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <<body>{{ga_code}}<div class="root"><div class="vbox wb_container" id="wb_header"> <div id="wb_element_instance79" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div></div> <div class="vbox wb_container" id="wb_main"> <?php() if($_SESSION['logged_in']); {); ?> <div id="wb_element_instance80" class="wb_element"><a class="wb_button" href="Login/"><span></span></a></div><div id="wb_element_instance83" class="wb_element" style=" overflow: hidden;">< <iframe src="https://docs.google.com/spreadsheets/d/1zkxOxRwqhGstemnqFAPrUVrAGtbE7JHAQgxemcqOcHY/edit#gid=0" width="100%" height="4000" frameborder="0" scrolling="yes"></iframe> <?php (}); ?> </div><div id="wb_element_instance84" class="wb_element" style="width: 100%;"> ?> <?php global $show_comments; if (isset($show_comments) && $show_comments) { renderComments(1); ?> <script type="text/javascript"> $(function() { var block = $("#wb_element_instance92"); var comments = block.children(".wb_comments").eq(0); var contentBlock = $("#wb_main"); contentBlock.height(contentBlock.height() + comments.height()); }); </script> <?php } else { ?> <script type="text/javascript"> $(function() { $("#wb_element_instance92").hide(); }); </script> <?php } ?> </div></div> <div class="vbox wb_container" id="wb_footer" style="height: 114px;"> <div id="wb_element_instance85" class="wb_element"><ul class="hmenu"><li><a href="Login-Check/" target="_self" title="Login Check">Login Check</a></li></ul></div><div id="wb_element_instance89" class="wb_element" style=" line-height: normal;"><p class="wb-stl-footer">© 2015 <a href="http://civilization5.host56.com">civilization5.host56.com</a></p></div><div id="wb_element_instance90" class="wb_element"><div class="wb-stl-footer" style="white-space: nowrap;">Member of <i class="icon-wb-logo"></i><a href="http://zyro.com/examples/" target="_blank" title="Zyro - Website Builder">Zyro</a></div><script type="text/javascript"> var _siteProBadge = _siteProBadge || []; _siteProBadge.push({hash: "1b73f084f0336c5299e27cb60719c633", cont: "wb_element_instance90"}); (function() { var script = document.createElement("script"); script.type = "text/javascript"; script.async = true; script.src = "http://zyro.com/examples/getjs/"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(script, s); })(); </script></div><div id="wb_element_instance93" class="wb_element" style="text-align: center; width: 100%;"><div class="wb_footer"></div><script type="text/javascript"> $(function() { var footer = $(".wb_footer"); var html = (footer.html() + "").replace(/^\s+|\s+$/g, ""); if (!html) { footer.parent().remove(); footer = $("#wb_footer"); footer.height(194); } }); </script></div></div><div class="wb_sbg"></div></div></body> </html> Code (markup): Parse error: syntax error, unexpected T_IF in /home/a6634782/public_html/zyro/1.php on line 35 it fixed the problem, but now a new one popped up, there is no IF in row 35, why would it error for it?
Uh... mate, you really need to learn to PHP... Here, use this: <?php if ($_SESSION['logged_in']) { ?> Code (markup): and this: <?php }; ?> Code (markup):
that worked, i modified it a bit and put it at the top and bottom of the code, works like a charm, thanks!