3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); session_start(); if (!isset($_SESSION['username'])) { header("location:login.php?error=1"); } elseif (!isset($_SESSION['id'])) { header("location:login.php?error=1"); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; define("DB_HOST","mysql117.loopia.se"); define("DB_USER","normal@i103189"); define("DB_PASS","KungMicke87"); define("DB_NAME","indiehjaerta_com"); if (isset($_POST['add'])) { if (isset($_POST['forumid']) && (!empty($_POST['forumid']))) { if (isset($_POST['threadid']) && (!empty($_POST['threadid']))) { // Connect to MySQLi $sqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Error: ".mysqli_error($sqli)); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $saveThread = TRUE; $emptyText = FALSE; $text = mysqli_real_escape_string($sqli, $_POST['text']); $fid = mysqli_real_escape_string($sqli, $_POST['forumid']); $tid = mysqli_real_escape_string($sqli, $_POST['threadid']); $query = mysqli_query($sqli,"SELECT * FROM forumcat WHERE id='$fid'") or die("Error: ".mysqli_error($sqli)); $resultsCategory = mysqli_num_rows($query); $query2 = mysqli_query($sqli,"SELECT * FROM forumtopics WHERE id='$tid'") or die("Error: ".mysqli_error($sqli)); $resultsThread = mysqli_num_rows($query2); if ($resultsCategory == 0) { $error = "No such CategoryID."; } elseif ($resultsThread == 0) { $error = "No such resultsThreadID."; } else { $timestamp = date('Y-m-d H:i:s'); $userid = $_SESSION['id']; $ip = ip2long($_SERVER['REMOTE_ADDR']); if (empty($text)) { $emptyText = TRUE; $saveThread = FALSE; } if ($saveThread == TRUE) { $addquery = mysqli_query($sqli,"INSERT INTO forumreplies (`text`, `categoryid`, 'threadid`, `userid`, `timestamp`, `ipaddress`) VALUES ('$text', '$fid', '$tid', '$userid', '$timestamp', '$ip')"); $tid = mysqli_insert_id($addquery); header("location:forummessage.php?added=thread&fid=$fid&tid=$tid"); } } } } else { // Connect to MySQLi $sqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Error: ".mysqli_error($sqli)); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $saveThread = TRUE; $emptySubject = FALSE; $emptyText = FALSE; $subject = mysqli_real_escape_string($sqli, $_POST['subject']); $text = mysqli_real_escape_string($sqli, $_POST['text']); $fid = mysqli_real_escape_string($sqli, $_POST['forumid']); $query = mysqli_query($sqli,"SELECT * FROM forumcat WHERE id='$fid'") or die("Error: ".mysqli_error($sqli)); $results = mysqli_num_rows($query); if ($results == 0) { $error = "No such CategoryID."; } else { $timestamp = date('Y-m-d H:i:s'); $userid = $_SESSION['id']; $ip = ip2long($_SERVER['REMOTE_ADDR']); if (empty($subject)) { $emptySubject = TRUE; $saveThread = FALSE; } elseif (empty($text)) { $emptyText = TRUE; $saveThread = FALSE; } if ($saveThread == TRUE) { $addquery = mysqli_query($sqli,"INSERT INTO forumtopics (`threadname`, `text`, `categoryid`, `userid`, `timestamp`, `ipaddress`) VALUES ('$subject', '$text', '$fid', '$userid', '$timestamp', '$ip')"); $tid = mysqli_insert_id($addquery); header("location:forummessage.php?added=thread&fid=$fid&tid=$tid"); } } } } else { echo "No ForumID set."; } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>indiehjaerta.com - Forum</title> <link href="style_test.css" rel="stylesheet" type="text/css" /> </head> <body> <a href="login.php">Login<a/> - <a href="admin.php">Admin<a/> - <a href="members.php">Members<a/> - <a href="register.php">Register<a/> - <a href="blog.php">Blog<a/> - <a href="news.php">News<a/> - <a href="event.php">Event<a/> - <a href="forum.php">Forum<a/> - <a href="logout.php">Logout<a/> <br /> <hr /> <br /> <?php if (isset($_GET['added']) && ($_GET['added'] == 'thread')) { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Thread Created</strong></td> </tr> <tr> <td colspan="3"><a href="forum.php?fid=<?php echo $_GET['fid'] ?>&tid=<?php echo $_GET['tid'] ?>" style="color: black">Link to thread.</a></td> </tr> </table> </td> </tr> </table> <?php } elseif (isset($_GET['action']) && $_GET['action'] == 'new') { if (isset($_GET['type']) && $_GET['type'] == 'thread') { if (isset($_GET['fid']) && empty(!$_GET['fid'])) { if (isset($_GET['tid']) && empty(!$_GET['tid'])) { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <form method="post" action=""> <input name="forumid" type="hidden" id="forumid" value="<?php echo $_GET['fid'] ?>"> <input name="threadid" type="hidden" id="threadid" value="<?php echo $_GET['tid'] ?>"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Answer to Thread</strong></td> </tr> <tr> <td colspan="3"><?php if(isset($error)) { echo $error; } ?></td> </tr> <tr> <td width="78"><strong>Subject</strong></td> <td width="6">:</td> <td width="294"><input name="subject" type="text" id="subject" readonly></td> </tr> <tr> <td>Story</td> <td>:</td> <td><textarea name="text" type="text" id="text" rows="3"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="add" value="Post"></td> </tr> </table> </td> </form> </tr> </table> <?php } else { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <form method="post" action=""> <input name="forumid" type="hidden" id="forumid" value="<?php echo $_GET['fid'] ?>"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Create Thread</strong></td> </tr> <tr> <td colspan="3"><?php if(isset($error)) { echo $error; } ?></td> </tr> <tr> <td width="78"><strong>Subject</strong></td> <td width="6">:</td> <td width="294"><input name="subject" type="text" id="subject"></td> </tr> <tr> <td>Story</td> <td>:</td> <td><textarea name="text" type="text" id="text" rows="3"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="add" value="Post"></td> </tr> </table> </td> </form> </tr> </table> <?php } } else { echo "Forum ID missing."; } } } else { echo "Nothing to see here."; } ?> <?php $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo '<span class="text">Page generated in '.$total_time.' seconds.</span><br />'; ?> </body> </html>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.4.29
Parse error: syntax error, unexpected '}' in /in/QJYX8 on line 145
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '}' in /in/QJYX8 on line 145
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/QJYX8 on line 145
Process exited with code 255.