Seeing other users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • The1corrupted
    New Member
    • Feb 2007
    • 134

    #1

    Seeing other users

    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=mys ql_query("SELEC T *
    FROM `user_table`
    WHERE `ns`='$x'
    AND `ew`='$y'
    AND `ud`='$z'
    AND `active`='1'");
    $checkarray=mys ql_fetch_array( $checklocal);

    while ($checkarray=my sql_fetch_array ($checklocal)) {

    echo $checkarray['cn']." is here<br>";
    }
    ?>[/PHP]
  • Stephan
    New Member
    • Feb 2007
    • 5

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

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

    while ($checkarray=my sql_fetch_array ($checklocal)) {

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

    is their any error?

    Comment

    • The1corrupted
      New Member
      • Feb 2007
      • 134

      #3
      There are no errors being reflected but it just doesn't show up...

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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=my sql_query("SELE CT *
        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=my sql_fetch_array ($checklocal)) {
        echo $checkarray['cn']." is here<br>";
        }
        }

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

        Ronald :cool:

        Comment

        • The1corrupted
          New Member
          • Feb 2007
          • 134

          #5
          Great! Now I can code everything else that uses this as a base. Thanks a lot.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            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:

            Comment

            • The1corrupted
              New Member
              • Feb 2007
              • 134

              #7
              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.

              Comment

              Working...