Bug with PHP 7

Ask about a PHP problem here.
Post Reply
wrichards8
Posts: 66
Joined: Thu Jan 12, 2012 3:54 pm
Contact:

Bug with PHP 7

Post by wrichards8 »

Has anyone else noticed this?

I am currently developing a PHP knowledge base system. I am using the latest version of XAMPP with PHP 7. I'm not sure if I am doing something wrong but whenever I try and start the session, the page doesn't load, Chrome resets the connection, Internet Explorer says there is an error and the page won't load.

I have it working in development when I don't start the session but,when I do and I hit refresh, the page refuses to even load. Is it just my machine,

For the record: I am not currently passing any options to session_start();

I apologise it this doesn't make sense. I wander if anyone else has noticed this
User avatar
KnightMaire
Posts: 29
Joined: Thu May 05, 2011 9:03 pm

Re: Bug with PHP 7

Post by KnightMaire »

99.9% of the time it is user-error. Post your code
wrichards8
Posts: 66
Joined: Thu Jan 12, 2012 3:54 pm
Contact:

Re: Bug with PHP 7

Post by wrichards8 »

OK... The file that I am including on every page is:

[syntax=php]<?php error_reporting(E_ALL);
session_start();
$connection = new mysqli("localhost","root", "", "codebase");
$path = dirname(__FILE__);
require("{$path}/functions.php");
function display_header($title)
{
$output = array();
$output[] = "<!DOCTYPE html>";
$output[] = "<html lang=\"EN\">";
$output[] = "<head>";
$output[] = "<title>{$title}</title>";
$output[] = "<link rel=\"stylesheet\" href=\"main.css\">";
$output[] = "</head>";
$output[] = "<body>";
$output[] = "<div id=\"content\">";
$output[] = "<h1>The Knowledge Base</h1>";
return array(implode("\n", $output), 1);
}

function display_footer($page)
{
if($page == "Home")
{
$left = "<a href=\"register.php\">Register</a>";
$right = "<a href=\"signin.php\">Sign In</a>";
}
elseif($page == "Register")
{
$left = "<a href=\"index.php\">Home</a>";
$right = "<a href=\"signin.php\">Sign In</a>";
}
elseif($page == "Sign In")
{
$left = "<a href=\"register.php\">Register</a>";
$right = "<a href=\"index.php\">Home</a>";
}
$output = array();
$output[] = "<div class=\"footer\">";
$output[] = "<div class=\"left\">";
$output[] = "{$left}";
$output[] = "</div>";
$output[] = "<div class=\"right\">";
$output[] = "{$right}";
$output[] = "</div>";
$output[] = "</div>";
$output[] = "</div>";
$output[] = "</body>";
$output[] = "</html>";
return implode("\n", $output);
}
?>[/syntax]

The index page looks like:

[syntax=php]<?php require("functions/output.php");
echo display_header("Home Page")[0];
if(empty($_GET["cid"])==TRUE)
{
$categories = get_categories($connection);
echo "<table>\n";
echo "<thead>\n";
echo "<tr>\n";
echo "<th scope\"col\">Category Name</th>\n";
echo "<th scope\"col\">Count</th>\n";
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
foreach($categories as $category)
{
echo "<tr>\n";
echo "<th scope=\"row\"><a href=\"index.php?cid={$category["id"]}\">{$category["name"]}</a></th>\n";
echo "<td>{$category["count"]}</td>\n";
echo "</tr>\n";
}
echo "</tbody>\n";
echo "</table>\n";
}
else
{
$cid = (int)$_GET["cid"];
}
echo display_footer("Home");
?>[/syntax]
wrichards8
Posts: 66
Joined: Thu Jan 12, 2012 3:54 pm
Contact:

Re: Bug with PHP 7

Post by wrichards8 »

Weird, I installed Xdebug and it works
User avatar
KnightMaire
Posts: 29
Joined: Thu May 05, 2011 9:03 pm

Re: Bug with PHP 7

Post by KnightMaire »

Might have needed a service restart
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Bug with PHP 7

Post by jacek »

Ooo someone is experimenting with PHP 7 before I even did :P It has some features that I love thought!

the reason you got a blank page might have been because of the display_errors setting in the php.ini. By default this is set to false and means any error at all will just cause the result to be a blank page.

I think xdebug overrides this setting so that could be why it started working.

All guessing there :P
Image
Post Reply