By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

Seeing other users

The1corrupted
100+
P: 134
Okay, I've toyed with this and it seems you either get all (inactive and active users) on a list or you get none at all... I'm trying to split them and it's not being nice about it. I've even made a new field in the MySQL table. Basically, it looks a little something like this..

[PHP]
<?php
session_start();
include ('user_conn.php');
$x=$_SESSION['xcoord'];
$y=$_SESSION['ycoord'];
$z=$_SESSION['zcoord'];

$checklocal=mysql_query("SELECT *
FROM `user_table`
WHERE `ns`='$x'
AND `ew`='$y'
AND `ud`='$z'
AND `active`='1'");
$checkarray=mysql_fetch_array($checklocal);

while ($checkarray=mysql_fetch_array($checklocal)) {

echo $checkarray['cn']." is here<br>";
}
?>[/PHP]
Feb 22 '07 #1
Share this Question
Share on Google+
6 Replies


P: 5
[PHP]
<?php
session_start();
include ('user_conn.php');
$x=$_SESSION['xcoord'];
$y=$_SESSION['ycoord'];
$z=$_SESSION['zcoord'];

$checklocal=mysql_query("SELECT *
FROM `user_table`
WHERE `ns`='$x'
AND `ew`='$y'
AND `ud`='$z'
AND `active`='1'");
$checkarray=mysql_fetch_array($checklocal); /*<--- here is a mistake will be defined twice...*/

while ($checkarray=mysql_fetch_array($checklocal)) {

echo $checkarray['cn']." is here<br>";
}
?>[/PHP][/quote]

is their any error?
Feb 22 '07 #2

The1corrupted
100+
P: 134
There are no errors being reflected but it just doesn't show up...
Feb 22 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
Firstly, the 1st $checkarray=.. must be taken out.
Secondly, check any errors in the select.
Thirdly, do not assume that there is a result, so check the number of rows returned. The following has all 3 coded:

[php]
if ($checklocal=mysql_query("SELECT *
FROM `user_table`
WHERE `ns`='$x'
AND `ew`='$y'
AND `ud`='$z'
AND `active`='1'")

or die ("Select error: "mysql_error());

// only fetch when there is a result
if (mysql_num_rows($checklocal) > 0) {

// loop through the result set
while ($checkarray=mysql_fetch_array($checklocal)) {
echo $checkarray['cn']." is here<br>";
}
}

// issue message when no result
else
echo 'No users active';[/php]

Ronald :cool:
Feb 23 '07 #4

The1corrupted
100+
P: 134
Great! Now I can code everything else that uses this as a base. Thanks a lot.
Feb 23 '07 #5

ronverdonk
Expert 2.5K+
P: 4,258
You are welcome.

However, I don't really understand what you mean by "Now I can code everything else that uses this as a base". Copying code without knowing what it actually does, and why, is a dangerous path for a programmer.

Ronald :cool:
Feb 23 '07 #6

The1corrupted
100+
P: 134
I do know what it does, only now it doesn't work right because I have to update a few things... But yes, there will be a chat system based off of this (I'll simply include it into the file or the like) and then the site will be done.
Feb 24 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.