3v4l.org

run code in 300+ PHP versions simultaneously
<?php //************************************************************* // place $req_status any where it will show the button/msg etc //************************************************************* //$user_email = email@example.com // get id by matching email address $result = mysql_query("SELECT id FROM tbluser WHERE email = '$user_email'"); if (!$result) { echo 'Could not run query'; } $row = mysql_fetch_assoc($result); $user_id = $row['id']; // id of the user //logged in. I assumed that you have the user id and profile id as follows. //$_SESSION['user_id'] = $user_id; if($_GET['fid']){ // ---------------------------------------------------- $friend_id = $_GET['fid']; // profile user id. // it shows "Friends" if user is friend. or "Add friend" or "Request pending" $query1="SELECT * FROM friends WHERE (user_id = '$user_id' AND friend_id = '$friend_id') OR (friend_id = '$friend_id' AND user_id = '$user_id')"; $result = mysql_query($query1); $row = mysql_num_rows($result); if ($row == 1) { // exist, whether it's active or not while($row = mysql_fetch_assoc($result)) { if ($row['status'] == 1) { echo "Friends"; } elseif ($row['status'] == 0) { if($row['user_id'] == $user_id){ $req_status = "Request pending"; //echo "Request pending"; } elseif($user_id == $row['friend_id']) { $uid = $row["user_id"]; $req_status = '<a href="add_friend.php?fid=$uid">Accept request</a> or <a href="ignore_request.php?fid=$uid">Ignore</a>'; //echo "<a href='add_friend.php?fid=".$row['user_id']."'>Accept request</a> or <a } } else { if($row['user_id'] == $user_id){ $req_status = "Request pending"; //echo "Request pending"; } else { $req_status = '<a href="add_friend.php?fid='.$friend_id.'">Add Friend</a>'; //echo "<a href='add_friend.php?fid=".$friend_id."'>Add Friend</a>"; } } } } else { // if the relationship don't exist $req_status = '<a href="add_friend.php?fid='.$friend_id.'">Add friend</a>'; //echo "<a href='add_friend.php?fid=".$friend_id."'>Add friend</a>"; } // ---------------------------------------------------- } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/M8R3r:10 Stack trace: #0 {main} thrown in /in/M8R3r on line 10
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.12 ms | 401 KiB | 8 Q