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($_GET['id']){ $gid = $_GET['id']; $qcheck = mysql_query("SELECT * FROM groups WHERE id = '$gid'") or die("Error! Cheating the system is not tolerated here!"); $g = mysql_fetch_array($qcheck); $type = $g['type']; $qv = mysql_num_rows($qcheck); if($qv==0){ header("Location: /groups/?msg=No such group exists!"); } $time=time(); $qgroups = mysql_query("SELECT * FROM groupmembers WHERE member = '$user_id' AND id = '$gid' AND flag = '1'"); $countgroups = mysql_num_rows($qgroups); if($countgroups == 1){ die("Error: You are already a member of this group"); } else { $qchk = mysql_query("SELECT * FROM groupmembers WHERE member = '$user_id' AND id = '$gid'"); $grp = mysql_fetch_array($qchk); if($grp['flag']=='0'){ mysql_query("UPDATE groupmembers SET flag = '2' WHERE `member`='$user_id' AND `id`='$gid'") or die("Error occured!"); header("Location: /groups/?id=".$gid."&msg=You was a deleted or kickedout member of this group. However, the request to join this group is sent to the admin"); } elseif($grp['flag']=='2'){ header("Location: /groups/?id=".$gid."&msg=Your request to join this group is already pending!"); } elseif($grp['flag']=='3') { header("Location /groups/?id=".$gid."&msg=Your request to join this group is already pending!"); } else { if($type=='closed'){ $query = mysql_query("INSERT INTO `groupmembers` (id, member, flag, created) VALUES ('$gid', '$user_id', '3','$time')") or die(mysql_error()); header("Location: /groups/?id=".$gid."&msg=Your request to join the group is sent!"); } elseif($type=='open'){ $query = mysql_query("INSERT INTO `groupmembers` (id, member, flag, created) VALUES ('$gid', '$user_id', '1','$time')") or die(mysql_error()); header("Location: /groups/?id=".$gid."&msg=You are now a member of this group"); } else { header("Location: /groups/?msg=Error: Group not found!"); } } } } else { echo "Invalid access"; } ?>
Output for 7.0.0 - 7.1.0
Warning: include_once(db.php): failed to open stream: No such file or directory in /in/aFnsJ on line 4 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/aFnsJ:8 Stack trace: #0 {main} thrown in /in/aFnsJ on line 8
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Warning: include_once(db.php): failed to open stream: No such file or directory in /in/aFnsJ on line 4 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Fatal error: Call to undefined function mysql_query() in /in/aFnsJ on line 8
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/aFnsJ on line 4 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Fatal error: Call to undefined function mysql_query() in /in/aFnsJ on line 8
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/aFnsJ on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/aFnsJ:2) in /in/aFnsJ on line 2 Warning: include_once(db.php): failed to open stream: No such file or directory in /in/aFnsJ on line 4 Warning: include_once(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Fatal error: Call to undefined function mysql_query() in /in/aFnsJ on line 8
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/aFnsJ on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/aFnsJ:2) in /in/aFnsJ on line 2 Warning: main(db.php): failed to open stream: No such file or directory in /in/aFnsJ on line 4 Warning: main(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Fatal error: Call to undefined function mysql_query() in /in/aFnsJ on line 8
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/aFnsJ on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/aFnsJ:2) in /in/aFnsJ on line 2 Warning: main(db.php): failed to open stream: No such file or directory in /in/aFnsJ on line 4 Warning: main(): Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/aFnsJ on line 8 Warning: mysql_query(): A link to the server could not be established in /in/aFnsJ on line 8 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/aFnsJ 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/aFnsJ:2) in /in/aFnsJ on line 2 Warning: main(db.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/aFnsJ on line 4 Warning: main() [http://www.php.net/function.main]: Failed opening 'db.php' for inclusion (include_path='.:') in /in/aFnsJ on line 4 Notice: Undefined index: email in /in/aFnsJ on line 6 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/aFnsJ on line 8 Warning: mysql_query() [http://www.php.net/function.mysql-query]: A link to the server could not be established in /in/aFnsJ on line 8 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)