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'] { $req_status = '<a href="add_friend.php?fid=$row["user_id"]">Accept request</a> or <a href="ignore_request.php?fid=$row["user_id"]">Ignore</a>'; //echo "<a href='add_friend.php?fid=".$row['user_id']."'>Accept request</a> or <a href='ignore_request.php?fid=".$row['user_id']."'>Ignore</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 5.3.0 - 5.3.26, 5.4.0 - 5.4.16
Parse error: syntax error, unexpected ';' in /in/FTLhn on line 45
Process exited with code 255.

preferences:
176.56 ms | 1387 KiB | 51 Q