Recent Posts
PHP | 6 sec ago
None | 9 sec ago
None | 12 sec ago
C# | 15 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 2 min ago
None | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Flippz on the 10th of Feb 2010 12:58:08 AM Download | Raw | Embed | Report
  1. <?php
  2.  
  3. $userId=$_REQUEST["userId"];
  4.  
  5. include('config.inc.php');
  6. include('database.inc.php');
  7. $randomUserId=0;
  8.  
  9. $result      =mysql_query("SELECT * FROM chats WHERE userId = $userId ");
  10.  
  11. while ($row=mysql_fetch_array($result))
  12.     {
  13.     $randomUserId=$row["randomUserId"];
  14.     }
  15.  
  16. if ($randomUserId == 0)
  17.     {
  18.     $result=mysql_query("SELECT * FROM users WHERE id <> $userId AND inchat like 'N' ORDER BY RAND() LIMIT 1");
  19.  
  20.     while ($row=mysql_fetch_array($result))
  21.         {
  22.         $randomUserId=$row["id"];
  23.         }
  24.  
  25.     if ($randomUserId != 0)
  26.         {
  27.         mysql_query("INSERT INTO chats (userId,randomUserId) values($userId, $randomUserId) ");
  28.         mysql_query("INSERT INTO chats (userId,randomUserId) values($randomUserId, $userId) ");
  29.  
  30.         mysql_query("UPDATE users SET inchat='Y' WHERE id = $userId ");
  31.         mysql_query("UPDATE users SET inchat='Y' WHERE id = $randomUserId ");
  32.         }
  33.     }
  34.  
  35. echo $randomUserId;
  36. mysql_close($con);
  37. ?>
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: