im using this script to display how many users are online...

<?php 
//fill in some basic info
$server = "server"; 
$db_user = "user"; 
$db_pass = "pass"; 
$database = "database"; 
$timeoutseconds = 300; 

//get the time
$timestamp = time(); 
$timeout = $timestamp-$timeoutseconds; 

//connect to database
mysql_connect($server, $db_user, $db_pass); 

//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); 
if(!($insert)) { 
print "Useronline Insert Failed > "; 
} 

//delete values when they leave
$delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout"); 
if(!($delete)) { 
print "Useronline Delete Failed > "; 
} 

//grab the results
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'"); 
if(!($result)) { 
print "Useronline Select Error > "; 
} 

//number of rows = the number of people online
$user = mysql_num_rows($result); 


//spit out the results
mysql_close(); 
if($user == 1) { 
print("$user user online\n"); 
} else { 
print("$user users online\n"); 
} 
?>

But it displays the output text in black....i need it in white?

how do i change the text to white?

thnkx

    onlinegamesnz wrote:

    But it displays the output text in black....i need it in white?
    how do i change the text to white?
    thnkx

    remember
    what I told you, in another topic.
    You even said: Thank You, halojoy 🙂
    I suppose your PHP code is alright,
    and then you cn use one of the following options:

    For a whole paragraph with white text:

    <p style="color:white">my text
    line2
    next line</p>

    Some, like me, prefer to use <div> instead of <p>:

    <div style="color:white">my text
    line2
    next line</div>

    If you need only 1 line of white color text:

    <span style="color:white">my text, on this line only</span>

      The easiest way is to just change the end of your script, like this;

      if($user == 1) { 
      print('<span style="color:#fff">$user user online\n</span>'); 
      } else { 
      print('<span style="color:#fff">$users user online\n</span>'); 
      } 
      ?>
      

      It would be nicer to include give the span an id and put the style in a style sheet or something...

      EDIT: I left that tab open and forgot to click post reply... Oops. I see now I've been beaten to it!

        Don't write your DB name and pass here 😉

        And also shouldn't:

        $timeoutseconds = 300;
        
        //get the time
        $timestamp = time();
        $timeout = $timestamp-$timeoutseconds;

        be:

        $timeoutseconds = 300;
        
        //get the time
        $timestamp = time();
        $timeout = $timestamp+$timeoutseconds;

        ?

          Don't write your DB name and pass here

          Good catch, I have edited the original post accordingly.

            halojoy is hilarious - ot I know but always informative and very entertaining.

              rodneykm wrote:

              halojoy is hilarious - ot I know but always informative and very entertaining.

              ot = off topic
              thanks rodney. for your encouraging words
              .. will keep me going here, at least for 2 week more.

              Now, life is not always on topic.
              My associations are not always RIGID and LIMITED to topic.
              Because nothing in life is that clean. It is not how we work in our minds.
              While we do one thing, work we may remeber some thing else
              or
              maybe make some fantasies about our female boss, while dealing with the economical calculations for our company.
              We may not speak it out .. it wouldnt gain our carrier.
              But who could blame us, if we give her a compliment for her new dress.

              It is only to make our boss happy and say we notice her beautiful clothing.

              A rigid, strict and mathematical logic person is afraid of anything outside his formula.
              Outside his little box of thinking.

              He will feel unsure and think he is breaking some law of not keeping exactly on track.

              My aim is too always stay Free in Mind.
              Be creative like a child with fantasy and joy of mind intact.

              I ask:
              .. do we have a life only to make PHP?
              Or do we use our interest in PHP to get together and meet other with same interest?

              Life is more than PHP.
              Life is the main thing.
              Not the formula.
              Life is free.
              We have fredom to express our selves.
              I express my self.
              It is my Human right.
              Nobody can yake that away from me, halojoy.

              I rather leave this place or any other place
              where some twisted person(s) tries to limit, to strangle and deny me my personal freedom.
              As long as I use it creatively
              with the aim to give some thing postive and maybe even useful
              to my freinds in PHP.

              This uis me. This is my personality.
              This is my self.
              And I wouldnt let my SELF down, betray who is me,
              just to satisfy some body else. Or some group that do not like the way I am.

              Never.

              Regards
              halojoy

                @:

                Could you please put that in

                tags? ;P

                  it just prints ' $user user online\n'

                  have a look www.tab-db.com/home.php

                  here the code i used

                  if($user == 1) { 
                  print('<span style="color:#fff">$user user online\n</span'); 
                  } else { 
                  print('<span style="color:#fff">$users user online\n</span>'); 
                  } 
                  ?>
                  

                  ??????? confused

                    Cut and paste this.

                    <?php
                    if($user == 1) {
                        print('<span style="color:#fff">'.$user.' user online\n</span');
                    } else {
                        print('<span style="color:#fff">'.$user.' user online\n</span>');
                    }
                    ?> 

                      thanks clonemaster, working perfectly

                      how would i make the text bold..and a smaller size?

                      cheers

                        <?php
                        if($user == 1) {
                            print '<span class="user-online">'.$user.'</span>';
                        } else {
                            print '<span class="user-online">'.$user.'</span>';
                        }
                        ?>

                        In your 'site.css' file add:

                        span.user-online {
                           color: rgb(255,255,255);
                           font-size: 10px;
                           font-weight: bold;
                        }
                        

                          cheers man u tha man.....

                          got anotha question.... i have a style sheet and a php file that links to that style sheet....u knw...but how do i know what css values in the STYLESHEET link to what DIVs or tables in the document...

                          So theres a DIV with a white background and text color white and i wanna make the background transparent and keep the txt color white. but white on white doesnt show up so i wanna make the background transparent in the DIV

                          so what part of the css do i edit...how do i know which value in the CSS links to that DIV to edit?

                          i know its a **** explanation....i tried

                          cheers

                            ive attached a zip of the files...

                            i cant change the text color to white...it changes in design view but when uploaded it goes back to white....not changing in the CSS i guess??

                              sorry, let me explain that again. I want all text to display white, it changes in design view...but when i upload it and open the page, it displays BLACK again. CSS not changing? go to www.tab-db.com and click the small text where it says CLICK HERE TO REGISTER. it will bring up the login form and the text Enter username [Email] and Enter Password is in black again

                                yo man, ive just noticed the user online script isnt working...seems like its not inserting into the table or something....i had 2 users go on and it still said 1 user online....worked before....can u check the code for me

                                <?php 
                                //fill in some basic info
                                $server = "dbhost"; 
                                $db_user = "dbuser"; 
                                $db_pass = "dbpass"; 
                                $database = "database"; 
                                $timeoutseconds = 300; 
                                
                                //get the time
                                $timestamp = time(); 
                                $timeout = $timestamp-$timeoutseconds; 
                                
                                //connect to database
                                mysql_connect($server, $db_user, $db_pass); 
                                
                                //insert the values
                                $insert = mysql_db_query($database, "INSERT INTO useronline VALUES
                                ('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); 
                                if(!($insert)) { 
                                print "Useronline Insert Failed > "; 
                                } 
                                
                                //delete values when they leave
                                $delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout"); 
                                if(!($delete)) { 
                                print "Useronline Delete Failed > "; 
                                } 
                                
                                //grab the results
                                $result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'"); 
                                if(!($result)) { 
                                print "Useronline Select Error > "; 
                                } 
                                
                                //number of rows = the number of people online
                                $user = mysql_num_rows($result); 
                                
                                
                                //spit out the results
                                mysql_close(); 
                                if($user == 1) { 
                                    print '<span class="user-online">'.$user.' user online</span>'; 
                                } else { 
                                    print '<span class="user-online">'.$user.' users online</span>'; 
                                } 
                                ?>
                                

                                  I haven't tested it, but try this re-write of the script.

                                  <?php
                                  
                                  // FILL IN SOME BASIC INFO
                                  $db_host = 'dbhost';
                                  $db_user = 'dbuser';
                                  $db_pass = 'dbpass';
                                  $db_name = 'dbname';
                                  $timeout = '300';
                                  
                                  // GET THE TIME
                                  $timestp = time();
                                  $timeout = $timestp - $timeout;
                                  
                                  // CONNECT TO DATABASE
                                  if (!link = mysqli_connect('$db_host', '$db_user', '$db_pass', '$db_name')) {
                                      print '<span class="user-online">'.mysqli_connect_error().'</span>';
                                  }
                                  
                                  // INSERT THE VALUES
                                  $insert = mysqli_query($link, "INSERT INTO useronline VALUES ('$timestp', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['PHP_SELF']."')");
                                  if (!$insert) {
                                      print '<span class="user-online">'.mysqli_error().'</span>';
                                  }
                                  
                                  // DELETE VALUES WHEN THEY LEAVE
                                  $delete = mysqli_query($link, "DELETE FROM useronline WHERE timestamp < $timeout");
                                  if (!$delete) {
                                      print '<span class="user-online">'.mysqli_error().'</span>';
                                  }
                                  
                                  // GRAB THE RESULTS
                                  $result = mysqli_querry($link, "SELECT DISTINCT ip FROM useronline WHERE file = '".$_SERVER['PHP_SELF']."'");
                                  if (!$result) {
                                      print '<span class="user-online">'.mysqli_error().'</span>';
                                  }
                                  
                                  // NUMBER OF ROWS = NUMBER OF PEOPLE ONLINE
                                  $user = mysql_num_rows($result);
                                  
                                  // SPIT OUT THE RESULTS
                                  if($user == '1') {
                                      print '<span class="user-online">'.$user.' user online</span>';
                                  } else {
                                      print '<span class="user-online">'.$user.' users online</span>';
                                  }
                                  
                                  // CLOSE DATABASE
                                  mysqli_close($link);
                                  
                                  ?>