3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.0.0 - 7.1.0
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 hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: user_id in /in/9lNXG on line 12 Warning: supplied argument is not a valid MySQL-Link resource in /in/9lNXG on line 14 Warning: supplied argument is not a valid MySQL-Link resource in /in/9lNXG on line 14
Output for 5.0.4 - 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.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)