3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php session_start(); //db include_once('db.php'); $user_email = $_SESSION['email']; $resultuid = mysql_query("SELECT `id` FROM `tbluser` WHERE `email` = '$user_email'") or die(mysql_error()); $row_id = mysql_fetch_assoc($resultuid); $user_id = $row_id['id']; // id of the user if(isSet($_POST['comment'])){ $gid=$_GET['gid']; $comment=$_POST['comment']; $msg_id=$_POST['msg_id']; $ip=$_SERVER['REMOTE_ADDR']; $comment=htmlentities($comment); $time=time(); $ip=$_SERVER['REMOTE_ADDR']; $query = mysql_query("SELECT id,comment FROM `group_comments` WHERE uid='$user_id' and msg_id='$msg_id' order by id desc limit 1 ") or die(mysql_error()); $result = mysql_fetch_array($query); if ($comment!=$result['comment']) { $query = mysql_query("INSERT INTO `group_comments` (comment, uid, msg_id, created) VALUES ('$comment', '$uid','$msg_id', '$time')") or die(mysql_error()); $newquery = mysql_query("SELECT id, uid, comment, msg_id, created FROM group_comments WHERE uid='$user_id' AND msg_id='$msg_id' order by id desc limit 1 "); $result = mysql_fetch_array($newquery); $com_id=$result['id']; $comment=tolink(htmlentities($result['comment'] )); $time=$result['created']; $uid=$result['uid']; $uinf = mysql_query("SELECT * FROM `tbluser` WHERE `id` = '$uid'") or die(mysql_error()); $row_user = mysql_fetch_array($uinf); $fullname = $row_user['fname'].' '.$row_user['lname']; // full name of user $user_photo = $row_user['photo']; $user_photo="http://nitofa.com/user_pics/users/$user_photo"; header("Location: /groups/?id=".$gid."&msg=Comment posted!#stcommentbody".$com_id); ?> <div class="stcommentbody" id="stcommentbody<?php echo $com_id; ?>"> <div class="stcommentimg"> <img src="<?php echo $user_photo; ?>" class='small_face'/> </div> <div class="stcommenttext"> <!-- <a class="stcommentdelete" href="#" id='<?php echo $com_id; ?>'>X</a> --> <b><a href="<?php echo 'http://nitofa.com/browse-user.php?fid='.$uid;?>"><?php echo $fullname; ?></a></b> <?php echo $comment; ?> <div class="stcommenttime"><?php time_stamp($time); ?></div> </div> </div> <?php } } ?>
Output for 7.0.0 - 7.1.0
Warning: include_once(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/CPDhh:9 Stack trace: #0 {main} thrown in /in/CPDhh on line 9
Process exited with code 255.
Output for hhvm-3.13.2
Warning: include_once(db.php): File not found in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Warning: supplied argument is not a valid MySQL-Link resource in /in/CPDhh on line 9 Warning: supplied argument is not a valid MySQL-Link resource in /in/CPDhh on line 9
Output for hhvm-3.10.0 - 3.12.0
Warning: File not found: db.php in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Warning: supplied argument is not a valid MySQL-Link resource in /in/CPDhh on line 9 Warning: supplied argument is not a valid MySQL-Link resource in /in/CPDhh on line 9
Output for 5.3.0 - 5.6.28
Warning: include_once(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Fatal error: Call to undefined function mysql_query() in /in/CPDhh on line 9
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Warning: include_once(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Fatal error: Call to undefined function mysql_query() in /in/CPDhh on line 9
Process exited with code 255.
Output for 5.1.0 - 5.2.2
Warning: session_start(): Cannot send session cookie - headers already sent in /in/CPDhh on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CPDhh:2) in /in/CPDhh on line 2 Warning: include_once(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Fatal error: Call to undefined function mysql_query() in /in/CPDhh on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: session_start(): Cannot send session cookie - headers already sent in /in/CPDhh on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CPDhh:2) in /in/CPDhh on line 2 Warning: main(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: main(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Fatal error: Call to undefined function mysql_query() in /in/CPDhh on line 9
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: session_start(): Cannot send session cookie - headers already sent in /in/CPDhh on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CPDhh:2) in /in/CPDhh on line 2 Warning: main(db.php): failed to open stream: No such file or directory in /in/CPDhh on line 5 Warning: main(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/CPDhh on line 9 Warning: mysql_query(): A link to the server could not be established in /in/CPDhh on line 9 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Output for 4.3.0 - 4.3.1
Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent in /in/CPDhh on line 2 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/CPDhh:2) in /in/CPDhh on line 2 Warning: main(db.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/CPDhh on line 5 Warning: main() [http://www.php.net/function.main]: Failed opening 'db.php' for inclusion (include_path='.:') in /in/CPDhh on line 5 Notice: Undefined index: email in /in/CPDhh on line 7 Warning: mysql_query() [http://www.php.net/function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/CPDhh on line 9 Warning: mysql_query() [http://www.php.net/function.mysql-query]: A link to the server could not be established in /in/CPDhh on line 9 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)