Bug #18063 Updated: Array not "set" when cross referencing.
| From: | sander@php.net | Date: | Sat, 29 Jun 2002 16:46:37 +0000 |
| Subject: | Bug #18063 Updated: Array not "set" when cross referencing. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12531@lists.php.net to get a copy of this message | ||
ID: 18063
Updated by: sander@php.net
Reported By: m3h431337n3wb13@hotmail.com
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: Win98SE
PHP Version: 4.2.1
New Comment:
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2002-06-29 12:37:58] m3h431337n3wb13@hotmail.com
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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18063&edit=1