3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $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"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>indiehjaerta.com - News</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="profile.php">Profile<a/> - <a href="logout.php">Logout<a/> <br /> <br /> <!-- New Post Start --> <?php if (isset($_GET['id'])) { // 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(); } $id = $_GET['id']; $query = mysqli_query($sqli, "SELECT * FROM news WHERE id='$id'") or die("Error: ".mysqli_error($sqli)); $checknumnews = mysqli_num_rows($query); // Check if news exists if($checknumnews == 0) { // No News echo '<span class="text">No News found matching ID!</span><br />'; } else { while ($row = mysqli_fetch_array($query)) { $id = $row['id']; ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>News</strong> </td> </tr> <tr> <td> <?php //Number of characters to show $chars = 25; while ($row = mysqli_fetch_array($query)) { $id = $row['id']; $story = $row['story']; ?> <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Subject:</strong></td> <td><strong><?php echo $row['headline'] ?></strong></td> </tr> <tr> <td colspan="2"><strong>Story:</strong></td> </tr> <tr> <td colspan="2"><?php echo $story ?></td> </tr> <?php $userid = $row['userid']; $query2 = mysqli_query($sqli, "SELECT * FROM members WHERE id='$userid'") or die("Error: ".mysqli_error($sqli)); while ($row2 = mysqli_fetch_array($query2)) { ?> <tr> <td><strong>Written by:</strong></td> <td><a href="profile.php?id=<?php echo $userid ?>" style="color: black;"><?php echo $row2['username'] ?></a></td> </tr> <?php } ?> <tr> <td><strong>Time:</strong></td> <td><?php echo $row['timestamp'] ?></td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> </table> <?php /* echo '<table border="0">'; echo '<tr>'; echo '<td><span class="text">Subject:</span></td>'; echo '<td><span class="text">' .$row['headline']. '</span></td>'; echo '</tr>'; $story = $row['story']; echo '<tr>'; echo '<td colspan="2"><span class="text">Story:</span></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><span class="text">' .$story. '</span></td>'; echo '</tr>'; $userid = $row['userid']; $query2 = mysqli_query($sqli, "SELECT * FROM members WHERE id='$userid'") or die("Error: ".mysqli_error($sqli)); while ($row2 = mysqli_fetch_array($query2)) { echo '<tr>'; echo '<td><span class="text">Written by:</span></td>'; echo '<td><span class="text"><a href="profile.php?id=' .$userid.' ">' .$row2['username']. '</a></span></td>'; echo '</tr>'; } echo '<tr>'; echo '<td><span class="text">Time:</span></td>'; echo '<td><span class="text">' .$row['timestamp']. '</span></td>'; echo '</tr>'; echo "</table><br />"; */ } } } 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(); } $query = mysqli_query($sqli, "SELECT * FROM news ORDER BY id") or die("Error: ".mysqli_error($sqli)); $checknumnews = mysqli_num_rows($query); // Check if user exists if($checknumnews == 0) { // No News echo '<span class="text">No News found in the database!</span><br />'; } else { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>News</strong> </td> </tr> <tr> <td> <?php //Number of characters to show $chars = 25; while ($row = mysqli_fetch_array($query)) { $id = $row['id']; ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong><a href="?id=<?php echo $id ?>" style="color: black;"><?php echo $row['headline'] ?></a></strong></td> </tr> <tr> <?php $story = $row['story']; if (strlen($story) >= $chars) { $story = substr($story,0,$chars); $story = substr($story,0,strrpos($story,' ')); $story = $story."... <a href='?id=$id' style='color: black;'>(Read more)</a>"; } ?> <td colspan="3"><?php echo $story ?></td> </tr> <?php $userid = $row['userid']; $query2 = mysqli_query($sqli, "SELECT * FROM members WHERE id='$userid'") or die("Error: ".mysqli_error($sqli)); while ($row2 = mysqli_fetch_array($query2)) { echo '<tr>'; echo '<td><strong>Written by:<strong></td>'; echo '<td><a href="profile.php?id=' .$userid.' " style="color: black;">' .$row2['username']. '</a></td>'; echo '</tr>'; } ?> <tr> <td><strong>Time:</strong></td> <td><?php echo $row['timestamp'] ?></td> </tr> </table> </td> </tr> <tr> <td> <?php } ?> </td> </tr> </table> <?php } } ?> <!-- New Post End --> <?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 5.4.0 - 5.4.29
Parse error: syntax error, unexpected 'else' (T_ELSE) in /in/RPho0 on line 183
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_ELSE in /in/RPho0 on line 183
Process exited with code 255.