3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<? include "db_info.php"; if(!$_COOKIE['level']){ echo "<script>alert('error');history.back(-1)</script>"; } $page_size=10; $page_list_size=10; $no = $_GET[no]; $search = $_GET['search']; if(!$no || $no<0) $no =0; if($search){ $query = "select * from board where title like '%$search%' or content like '%$search%' order by id desc limit $no, $page_size"; $result_count=mysql_query("select count(*) from board where title like '%$search%' or content like '%$search%'", $conn); }else{ $query = "select * from board order by id desc limit $no, $page_size"; $result_count=mysql_query("select count(*) from board", $conn); } echo "$query<br><br><br>"; $result = mysql_query($query, $conn); $result_row = mysql_fetch_row($result_count); $total_row = $result_row[0]; if($total_row <= 0) $total_row = 0; $total_page = ceil($total_row / $page_size); $current_page = ceil(($no+1)/$page_size); ?> <html> <head> <title>board</title> <br> <table> <tr> <td><a font size=2>yeonghoo2.com</a></td> <td width=280></td> <td align=left><form action=list.php method=get> <input type=text name=search> <input type=submit value=search> </form> </td> <table witdh=500 border=1 cellpadding=0 cellspacing=0> <tr height=20> <td width=30 align=center>no</td> <td width=370 align=center>title</td> <td width=50 align=center>user</td> <td width=60 align=center>date</td> <td width=40 align=center>view</td> </tr> <? while($row=mysql_fetch_array($result)){ ?> <tr> <td height=20 align=center> <a href="read.php?id=<?=$row[id]?>&no=<?=$no?>"> <?=$row[id]?></a> </td> <td height=20>&nbsp;<a href="read.php?id=<?=$row[id]?>&no=<?=$no?>"> <?=strip_tags($row[title],'<b><i>');?></a> </td> <td align=center height=20> <a href="mailto:<?=$row[email]?>"> <?=$row[name]?></a> </td> <td align=center height=20><?=$row[wdate]?> </td> <td align=center height=20><?=$row[view]?> </td> </tr> <? } mysql_close($conn); ?> </table> <table border=0> <tr> <td width=600 height=20 align=center rowspan=4> <? $start_page = floor(($current_page -1 ) / $page_list_size) * $page_list_size + 1; $end_page = $start_page + $page_list_size -1; if($total_page < $end_page) $end_page = $total_page; if(start_page >= $page_list_size){ $prev_list = ($start_page - 2) * $page_size; echo "<a href='$PHP_SELF?no=prev_list'><</a>"; } for($i=$start_page; $i<=$end_page; $i++){ $page= ($i-1)*$page_size; if($no != $page){ if(!$search){ echo "<a href='$PHP_SELF?no=$page'>"; }else{ echo "<a href='$PHP_SELF?no=$page&search=$search'>"; } } echo "$i&nbsp;"; if($no != $page ){ echo "</a>"; } } if($total_page > $end_page){ $next_list = $end_page * $page_size; echo "<a href=$PHP_SELF?no=$next_list>></a><p>"; } ?> </td> </tr> </table> <a href=write.php>write</a> <a href=logout.php>logout</a> </center> <? if($_COOKIE['level']==99){ echo "<a href=adm.php>adminpage</a>"; } ?> </html>
Output for 7.2.0
Warning: include(db_info.php): failed to open stream: No such file or directory in /in/QPhKW on line 2 Warning: include(): Failed opening 'db_info.php' for inclusion (include_path='.:') in /in/QPhKW on line 2 Notice: Undefined index: level in /in/QPhKW on line 4 <script>alert('error');history.back(-1)</script> Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /in/QPhKW on line 10 Notice: Undefined index: no in /in/QPhKW on line 10 Notice: Undefined index: search in /in/QPhKW on line 11 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/QPhKW:22 Stack trace: #0 {main} thrown in /in/QPhKW on line 22
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Warning: include(db_info.php): failed to open stream: No such file or directory in /in/QPhKW on line 2 Warning: include(): Failed opening 'db_info.php' for inclusion (include_path='.:') in /in/QPhKW on line 2 Notice: Undefined index: level in /in/QPhKW on line 4 <script>alert('error');history.back(-1)</script> Notice: Use of undefined constant no - assumed 'no' in /in/QPhKW on line 10 Notice: Undefined index: no in /in/QPhKW on line 10 Notice: Undefined index: search in /in/QPhKW on line 11 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/QPhKW:22 Stack trace: #0 {main} thrown in /in/QPhKW on line 22
Process exited with code 255.
Output for 5.4.1 - 5.6.28
Warning: include(db_info.php): failed to open stream: No such file or directory in /in/QPhKW on line 2 Warning: include(): Failed opening 'db_info.php' for inclusion (include_path='.:') in /in/QPhKW on line 2 Notice: Undefined index: level in /in/QPhKW on line 4 <script>alert('error');history.back(-1)</script> Notice: Use of undefined constant no - assumed 'no' in /in/QPhKW on line 10 Notice: Undefined index: no in /in/QPhKW on line 10 Notice: Undefined index: search in /in/QPhKW on line 11 Fatal error: Call to undefined function mysql_query() in /in/QPhKW on line 22
Process exited with code 255.
Output for 5.3.18 - 5.3.29
<? include "db_info.php"; if(!$_COOKIE['level']){ echo "<script>alert('error');history.back(-1)</script>"; } $page_size=10; $page_list_size=10; $no = $_GET[no]; $search = $_GET['search']; if(!$no || $no<0) $no =0; if($search){ $query = "select * from board where title like '%$search%' or content like '%$search%' order by id desc limit $no, $page_size"; $result_count=mysql_query("select count(*) from board where title like '%$search%' or content like '%$search%'", $conn); }else{ $query = "select * from board order by id desc limit $no, $page_size"; $result_count=mysql_query("select count(*) from board", $conn); } echo "$query<br><br><br>"; $result = mysql_query($query, $conn); $result_row = mysql_fetch_row($result_count); $total_row = $result_row[0]; if($total_row <= 0) $total_row = 0; $total_page = ceil($total_row / $page_size); $current_page = ceil(($no+1)/$page_size); ?> <html> <head> <title>board</title> <br> <table> <tr> <td><a font size=2>yeonghoo2.com</a></td> <td width=280></td> <td align=left><form action=list.php method=get> <input type=text name=search> <input type=submit value=search> </form> </td> <table witdh=500 border=1 cellpadding=0 cellspacing=0> <tr height=20> <td width=30 align=center>no</td> <td width=370 align=center>title</td> <td width=50 align=center>user</td> <td width=60 align=center>date</td> <td width=40 align=center>view</td> </tr> <? while($row=mysql_fetch_array($result)){ ?> <tr> <td height=20 align=center> <a href="read.php?id=<?=$row[id]?>&no=<?=$no?>"> <?=$row[id]?></a> </td> <td height=20>&nbsp;<a href="read.php?id=<?=$row[id]?>&no=<?=$no?>"> <?=strip_tags($row[title],'<b><i>');?></a> </td> <td align=center height=20> <a href="mailto:<?=$row[email]?>"> <?=$row[name]?></a> </td> <td align=center height=20><?=$row[wdate]?> </td> <td align=center height=20><?=$row[view]?> </td> </tr> <? } mysql_close($conn); ?> </table> <table border=0> <tr> <td width=600 height=20 align=center rowspan=4> <? $start_page = floor(($current_page -1 ) / $page_list_size) * $page_list_size + 1; $end_page = $start_page + $page_list_size -1; if($total_page < $end_page) $end_page = $total_page; if(start_page >= $page_list_size){ $prev_list = ($start_page - 2) * $page_size; echo "<a href='$PHP_SELF?no=prev_list'><</a>"; } for($i=$start_page; $i<=$end_page; $i++){ $page= ($i-1)*$page_size; if($no != $page){ if(!$search){ echo "<a href='$PHP_SELF?no=$page'>"; }else{ echo "<a href='$PHP_SELF?no=$page&search=$search'>"; } } echo "$i&nbsp;"; if($no != $page ){ echo "</a>"; } } if($total_page > $end_page){ $next_list = $end_page * $page_size; echo "<a href=$PHP_SELF?no=$next_list>></a><p>"; } ?> </td> </tr> </table> <a href=write.php>write</a> <a href=logout.php>logout</a> </center> <? if($_COOKIE['level']==99){ echo "<a href=adm.php>adminpage</a>"; } ?> </html>