php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18063 Array not "set" when cross referencing.
Submitted: 2002-06-29 12:37 UTC Modified: 2002-06-29 12:46 UTC
From: m3h431337n3wb13 at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.2.1 OS: Win98SE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: m3h431337n3wb13 at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-06-29 12:37 UTC] m3h431337n3wb13 at hotmail dot 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-29 12:46 UTC] sander@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC