Jump to content

DootThaLoop

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DootThaLoop's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here is the headers error I get: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/helloism/public_html/ynw/login/users.php:5) in /home/helloism/public_html/ynw/login/users.php on line 6
  2. I know the basic HTML structure.... and I understand what you're saying. But if I were to put the script in the HTML structure you're talking about...... <html> <head> <title></title> </head> <body> Script goes here... </body> </html> I get a headers error. Now I'm fairly new at PHP and this whole thing is a learning experience for me. I have been working several days at perfecting this script to no avail. Basically.... I'd just like to know what I'm doing wrong, and how to fix it, plain and simple. I'm not a PHP expert, I don't know all these big terms that you all use.
  3. I did exactly what you said and put "or die(mysql_error())"; after everything. But it doesn't display any error and also the usernames still don't display.
  4. When I remove the quotes I get errors: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/helloism/public_html/ynw/login/users.php on line 42 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/helloism/public_html/ynw/login/users.php on line 58 Also, its not an issue with the way I have my database setup?
  5. 'nowonline' is what contains their locations.
  6. Hi, I'm working on a userlist that will not only display the names of users logged into my site, but their locations as well. Except I ran into a bit of trouble with my database... I'm not very good at SQL so could someone tell me what is wrong with the database? The problem is that the userlist will display the user locations and not their names. Here is a screenshot: And here is the script. It is in two files. users.php: <?php session_start(); #Start the session include("getpage.php"); $hostname = "localhost"; #MySQL Hostname $username = "helloism_hellois"; #MySQL Username $password = "*********"; #MySQL Password $database = "helloism_login"; #MySQL Database $connect = mysql_connect(localhost, helloism_hellois, ********); #Connect to the mysql host $select_db = mysql_select_db(helloism_login, $connect); #Select the database if (isset($_SESSION['PHPSESSID'])) { #If the user is logged in, good for them, if not, they become an ip address $username = $_SESSION['username']; #Username } else { $username = $_SERVER['REMOTE_ADDR']; #Username is IP Address } $time = time(); #Current time $previous = "1"; #Time to check in seconds $timeout = $time-$previous; #Timeout $query = "SELECT * FROM active_users WHERE username=\"$username\" AND timestamp < \"$timeout\""; #Past 2 minutes $verify = mysql_query($query); #Execute query $row_verify = "mysql_fetch_assoc($verify)"; #Check if you have been here in two minutes if (!isset($row_verify['username'])) #See if you were found $query = "INSERT INTO online (username, timestamp) VALUES (\"$username\", \"$time\")"; #Put you on the online list $insert = mysql_query($query); #Execute query $query = "SELECT * FROM active_users WHERE timestamp < \"$timeout\""; #Check and see who is online ?> <font size="3" face="Courier New" color="FFFFFF"> <? $active_users = mysql_query($query); #Execute query $row_active_users = "mysql_fetch_assoc($nowonline)"; if (isset($row_active_users['nowonline'])) { do { echo ($row_active_users['nowonline'].""); } while($row_active_users = mysql_fetch_assoc($active_users)); } $online = mysql_query($query); #Execute query $row_online = "mysql_fetch_assoc($username)"; #Grab the users if (isset($row_online['username'])) { do { echo ($row_online['username'].""); #Output username echo '<br>'; #put a break after each database } while($row_online = mysql_fetch_assoc($online)); #Until all records are displayed } else { echo "No one's online."; #Inform user that no one is online } { echo $page; # will show the full page echo $QueryString; #echo query echo '<br>'; #put a break after each database } ?> <title>[:Users Online:]</title> </head> <body bgcolor="000000" text="FFFFFF"> </body> </html> And getpage.php: <?php session_start(); #Start the session $hostname = "localhost"; #MySQL Hostname $username = "helloism_hellois"; #MySQL Username $password = "********"; #MySQL Password $database = "helloism_login"; #MySQL Database $connect = mysql_connect(localhost, helloism_hellois, *********); #Connect to the mysql host $select_db = mysql_select_db(helloism_login, $connect); #Select the database $QueryString=""; foreach ($_GET as $key => $value) { $value = urlencode(stripslashes($value)); if($QueryString!="") $QueryString .="&"; $QueryString .= "$key=$value"; } $pageName=basename($_SERVER['REQUEST_URI']); $page =$pageName."?".$QueryString; $query = "INSERT INTO active_users (nowonline) VALUES ('$page')"; $sql = "SELECT (nowonline) FROM active_users"; $verify = mysql_query($query) or die(mysql_error()); $verified=mysql_query($sql)or die(mysql_error()); if($verify) { //dostuff }else{ //error } if($verified) { //dostuff }else{ //error } ?>
  7. Yeah I have that code, and it works for the most part. But I need to know what to do with my database [refer to image above].
  8. Ok here is my table [active_users]. Can someone tell me what exactly is wrong with it?
  9. Allright I managed to fix that error. But it still wont' display member names..... :/
  10. I changed it to that and I am still getting that error... I have a theory, maybe I did something incorrect with the 'nowonline' field? It's currently of the type varchar(30). Should I edit that somehow? Change the type, or add an index or something? I'm not very skilled with SQL....
  11. Okay now that I can see the issue, I'm getting this error.... what does it mean? Duplicate entry '' for key 1
  12. Worked like a charm for displaying the page locations.... but now my users' names are not being displayed for some reason.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.