Page 1 of 1

Site Broken in PHP 5.4 - Need help with changes (fixed)

Posted: Sat Aug 24, 2013 5:15 am
by Bigun
I'm trying to step through the code and find the major changes. One of the first changes I noticed is the following code no longer works as expected:

Code: Select all

<?php
if (!isset($_SESSION['userid'])) {
	//No one is logged in, kick them back
	?>
	<div id="body">
	<center><span class="info">You are not logged in, please wait one moment while we redirect you</span></center>
	<meta http-equiv="refresh" content="2;url=./">
	</div>
	<?php
	include('../footer.php');
	exit();
}
Normally I can jump in and out of PHP code to post some HTML, but now it seems if I jump out that PHP completely loses its place. It gives an error saying the last bracket was unexpected.

*edit*

I did some more research and this seems to have happened between version 5.3.27 and versions 5.4 and breaks even worse in 5.5 (warnings about SQL queries).

Re: Site Broken in PHP 5.4 - Need help with changes

Posted: Sat Aug 24, 2013 7:52 am
by Celauran
That code by itself looks fine. Could you post a bit more of the surrounding code and the exact errors you're encountering?

Re: Site Broken in PHP 5.4 - Need help with changes

Posted: Sat Aug 24, 2013 8:14 am
by Bigun
Only two lines before that:

Code: Select all

<?php
include('../header.php');
I can post some of header.php if it will help.

Re: Site Broken in PHP 5.4 - Need help with changes

Posted: Sat Aug 24, 2013 8:19 am
by Celauran
The code you have posted is running fine on 5.4.7

Re: Site Broken in PHP 5.4 - Need help with changes

Posted: Fri Aug 01, 2014 7:53 pm
by Bigun
I figured it out, turns out the include file included use of the following tags:

Code: Select all

<?
Which is disabled by default in the php.ini(short_open_tag = Off).

Is there any known security risk with leaving short open tags on?

Re: Site Broken in PHP 5.4 - Need help with changes (fixed)

Posted: Fri Aug 01, 2014 8:12 pm
by Celauran
It's not a security risk that I'm aware of, but it's definitely a bad practice as, as you've seen, it reduces code portability. Many (most?) servers will have short tags disabled.