3v4l.org

run code in 300+ PHP versions simultaneously
<?php //this code shows friend suggestions. //******************************************************************************** // // User Id wgaira ka code dekh lena, is script me use krne k liye. OK. $user_id set honi chahye! // //******************************************************************************** // select all users in table: tbluser $searchq = "SELECT * FROM tbluser WHERE user_id <> '$user_id' LIMIT 5"; // it will show 4/5 suggestions. change to whatever you want $searchresult = mysql_query($searchq) or die(mysql_error()); while($row_user = mysql_fetch_array($searchresult)){ // check if user is friend or not $fon="SELECT * FROM friends WHERE (user_id = '$user_id') OR (friend_id = '$user_id')"; $result = mysql_query($fon) or die(mysql_error()); $row = mysql_num_rows($result); // if user is not in friend list i.e $row=0 if ($row == 0) { $uid = $row_user['id']; $user_photo = $row_user['photo']; $fullname = $row_user['fname'].' '.$row_user['lname']; // you can change the link to add friend $add_friend_link = '<a style="font-size: small;" href="add_friend.php?fid='.$uid.'">Add as friend</a>'; //you can change this html to suit your needs $html = '<img src="'.$user_photo.'" align="absmiddle" alt="'.$fullname.'" title="'.$fullname.'"></img>'.$fullname.'<br/>'.$add_friend_link.' <br/><br/>'; //show the html code(friend suggestions) echo $html; //if user is in friend list, following code will show next friend suggestion } else { continue; } } ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $user_id in /in/9lNXG on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/9lNXG:14 Stack trace: #0 {main} thrown in /in/9lNXG on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined variable: user_id in /in/9lNXG on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/9lNXG:14 Stack trace: #0 {main} thrown in /in/9lNXG on line 14
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/9lNXG:14 Stack trace: #0 {main} thrown in /in/9lNXG on line 14
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Undefined variable: user_id in /in/9lNXG on line 12 Fatal error: Call to undefined function mysql_query() in /in/9lNXG on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: user_id in /in/9lNXG on line 12 Fatal error: Call to undefined function mysql_query() in /in/9lNXG on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Notice: Undefined variable: user_id in /in/9lNXG on line 12 Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/9lNXG on line 14 Warning: mysql_query(): A link to the server could not be established in /in/9lNXG on line 14 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: user_id in /in/9lNXG on line 12 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/9lNXG on line 14 Warning: mysql_query() [http://www.php.net/function.mysql-query]: A link to the server could not be established in /in/9lNXG on line 14 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

preferences:
222.1 ms | 402 KiB | 314 Q