|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2002-06-29 12:46 UTC] sander@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 06:00:01 2025 UTC | 
Ok, im trying to make a "User Online:" script, but one that prints out the amount of users on a page... e.g. Users online : 17 /index.php 6 /chat.php 3 /forums.php 8 I am using another script, but I like to rewrite my own. THis is what I have done so far. <?php $link_id = mysql_connect ("localhost", "######", "######"); mysql_select_db ("online", $link_id); $query = mysql_query ("SELECT DISTINCT ip FROM useronline", $link_id); while ($results = mysql_fetch_array ($query)) { $query = mysql_query ("SELECT file FROM useronline WHERE ip = '" . $results["ip"] . "'", $link_id); } ?> I know the first query is set, becuase I can loop through $result["ip"] and get it to print out the 10 IPs held in the database. But, on running this comand... I get the following error message. Notice: Undefined index: ip in C:\Apache\htdocs\online.php on line 8 Line 8: $query = mysql_query ("SELECT file FROM useronline WHERE ip = '" . $results["ip"] . "'", $link_id); Ive tried doing..... $temp_ip = $results["ip"]; $query = mysql_query ("SELECT file FROM useronline WHERE ip = '" . $temp_ip . "'", $link_id); With no avail. What I did find interesting is that. when using this script... <?php $link_id = mysql_connect ("localhost", "######", "######"); mysql_select_db ("online", $link_id); $query = mysql_query ("SELECT DISTINCT ip FROM useronline", $link_id); while ($results = mysql_fetch_array ($query)) { echo ($results["ip"] . "<br>"); //$query = mysql_query ("SELECT file FROM useronline WHERE ip = '" . $results["ip"] . "'", $link_id); } ?> It prints out all the 10 IP's in the DB, but notice the commented out "//$query"... only when its commented out will it echo $results["ip"]! This is a defualt install of the latest PHP binary for windows (APache 2 - in ISAPI mode). Hope this helps solve mine and anyone elses problems.