3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
// viewprofiles.php <?php include_once("header.php"); echo $user.' is currently logged in<br><br>'; echo <<<_END <form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> _END; $allusers = array(); //Create the $allusers array, comprised of all users except me $result = queryMysql("SELECT * FROM members"); $num = mysql_num_rows($result); for ($j = 0 ; $j < $num ; ++$j) { $row = mysql_fetch_row($result); if ($row[0] == $user) continue; $allusers[$j] = $row[0]; } //Create the $i_like_these_users array, comprised of all users i liked $result = queryMysql("SELECT * FROM likeprofile WHERE user='$user'"); $num = mysql_num_rows($result); for ($j = 0 ; $j < $num ; ++$j) { $row = mysql_fetch_row($result); $i_like_these_users[$j] = $row[1]; } //Create the $i_dislike_these_users array, comprised of all users i disliked $result = queryMysql("SELECT * FROM dislikeprofile WHERE user='$user'"); $num = mysql_num_rows($result); for ($j = 0 ; $j < $num ; ++$j) { $row = mysql_fetch_row($result); $i_dislike_these_users[$j] = $row[1]; } //Create the $usersiviewed array, comprised of all users i have either liked or disliked if (is_array($i_like_these_users) && is_array($i_dislike_these_users)) { $usersiviewed = array_merge($i_like_these_users,$i_dislike_these_users); } elseif(is_array($i_like_these_users)) { $usersiviewed = $i_like_these_users; } else { $usersiviewed = $i_dislike_these_users; } // this removes from the array $allusers (i.e., profiles i can view) all $usersviewed (i.e., all the profiles i have already either liked/disliked) if (is_array($usersiviewed)) { $peopleicanview = array_diff($allusers, $usersiviewed); $peopleicanview = array_values($peopleicanview); // this re-indexes the array } else { $peopleicanview = $allusers; $peopleicanview = array_values($peopleicanview); // this re-indexes the array } $current_user_profile = $peopleicanview[0]; echo 'check out '.$current_user_profile.'s picture <br />'; if (file_exists("$current_user_profile.jpg")) {echo "<img src='$current_user_profile.jpg' align='left' />";} // if i like or dislike this person, the likeprofile or dislikeprofile table is updated with my name and the name of the person who liked or disliked if (isset($_POST['choice']) && $_POST['choice'] == 'LIKE') { $ilike = $current_user_profile; $query = "INSERT INTO likeprofile VALUES" . "('$user', '$ilike')"; if (!queryMysql($query)) echo "INSERT failed: $query<br />" . mysql_error() . "<br /><br />"; } if (isset($_POST['choice']) && $_POST['choice'] == 'NEXT PROFILE') { $idontlike = $current_user_profile; $query = "INSERT INTO dislikeprofile VALUES" . "('$user', '$idontlike')"; if (!queryMysql($query)) echo "INSERT failed: $query<br />" . mysql_error() . "<br /><br />"; } ?>
Output for 7.0.0 - 7.1.0
// viewprofiles.php Warning: include_once(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: include_once(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Uncaught Error: Call to undefined function queryMysql() in /in/o8jYP:18 Stack trace: #0 {main} thrown in /in/o8jYP on line 18
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
// viewprofiles.php Warning: File not found: header.php in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function queryMysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 5.1.0 - 5.1.1, 5.1.3 - 5.6.28
// viewprofiles.php Warning: include_once(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: include_once(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function queryMysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 5.1.2
// viewprofiles.php Warning: include_once(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: include_once(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function queryMysql() in /in/o8jYP on line 19
Process exited with code 255.
Output for 5.0.4 - 5.0.5
// viewprofiles.php Warning: main(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function queryMysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.3
// viewprofiles.php Warning: main(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function queryMysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 4.4.5 - 4.4.9
// viewprofiles.php Warning: main(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function: querymysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.4
// viewprofiles.php Warning: main(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function: querymysql() in /in/o8jYP on line 18
Process exited with code 255.
Output for 4.4.2
// viewprofiles.php Warning: main(header.php): failed to open stream: No such file or directory in /in/o8jYP on line 3 Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function: querymysql() in /in/o8jYP on line 19
Process exited with code 255.
Output for 4.3.0 - 4.3.1
// viewprofiles.php Warning: main(header.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/o8jYP on line 3 Warning: main() [http://www.php.net/function.main]: Failed opening 'header.php' for inclusion (include_path='.:') in /in/o8jYP on line 3 Notice: Undefined variable: user in /in/o8jYP on line 5 is currently logged in<br><br><form method="post" action="viewprofiles.php"><pre> <input type="submit" name ="choice" value="LIKE" /> <input type="submit" name ="choice" value="NEXT PROFILE" /> </pre></form> Fatal error: Call to undefined function: querymysql() in /in/o8jYP on line 18