MrLarkins Posted November 23, 2008 Share Posted November 23, 2008 well, It's been a while since I've written anything. I was only ever a newblet in the first place at it. But I gave it my best shot. Can anyone help me out here? I just need a simple list shown. here's what I already have. <?php require "conf_global.php"; //-------------------------------- //Time to Connect //-------------------------------- $conn = mysql_pconnect ($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']) or die(mysql_error()); mysql_select_db ($INFO['sql_database']) or die(mysql_error()); //-------------------------------- //Talking With the DB //-------------------------------- $info = mysql_query ("SELECT * FROM ibf_members WHERE last_activity > time()-86400 ORDER BY members_display_name"); //------------------------- //The Info //------------------------- $array_one = mysql_fetch_array($info); $array_two = $array_one["members_display_name"]; $array_three = $array_one["mgroup"]; //------------------------------ //Member Group Color //------------------------------ if ($array_three = 6) { //admin $color = "#FFE910"; } elseif ($array_three = 7) { // OSK-Member $color = "#78A7BF"; } else { //Member $color = "#E5E8E9"; } //----------------------------------- //List 'Em //----------------------------------- echo ('<font size=-2 color="'.$color.'">'); echo ($array_two); echo ('</font>'); mysql_close($conn); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 23, 2008 Share Posted November 23, 2008 have fun <?php require "conf_global.php"; //-------------------------------- //Time to Connect //-------------------------------- $conn = mysql_pconnect ($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']) or die(mysql_error()); mysql_select_db ($INFO['sql_database']) or die(mysql_error()); //-------------------------------- //Talking With the DB //-------------------------------- $info = mysql_query ("SELECT * FROM ibf_members WHERE last_activity > time()-86400 ORDER BY members_display_name"); //------------------------- //The Info //------------------------- while($array=mysql_fetch_array($info)){; $array=$array["members_display_name"]; $array_two=$array["mgroup"]; } //------------------------------ //Member Group Color //------------------------------ if ($array_two==6) { //admin $color = "#FFE910"; } elseif ($array_two==7) { // OSK-Member $color = "#78A7BF"; } else { //Member $color = "#E5E8E9"; } //----------------------------------- //List 'Em //----------------------------------- echo '<font size=-2 color="'.$color.'">'; echo $array; echo '</font>'; mysql_close($conn); ?> Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 hmmm Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/oskgamin/public_html/forums/visitors.php on line 20 thats the 'while' statement and i'm just curious, did you think Line 13 was correct? Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted November 23, 2008 Share Posted November 23, 2008 Your query is wrong then. i don't remember if the > operator is built into mysql or not. Try running the query in phpmyadmin. Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 23, 2008 Share Posted November 23, 2008 change while($array=mysql_fetch_array($info)){; to while($array=mysql_fetch_array($info)){ Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 basically, i'm trying to grab everyone who has been active in the last 24 hours. $info = mysql_query ("SELECT * FROM ibf_members WHERE last_activity < time()-86400 ORDER BY members_display_name"); selectin all from table ibf_members where last activity is within 24 hours...i really don't think that msyql_query line is correct Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 23, 2008 Share Posted November 23, 2008 Read my post above. Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 sorry, i didnt mean to seem like i ignored it...i did remove the semicolon and it didn't change anything. Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted November 23, 2008 Share Posted November 23, 2008 Same here, can you try it in phpmyadmin or something similar? Because it'll tell you where the query is wrong. Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 not good, here's what phpMyadmin kicks back Error SQL query: SELECT * FROM ibf_members WHERE last_activity > time( ) -86400 ORDER BY members_display_name LIMIT 0 , 30 MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')-86400 ORDER BY members_display_name LIMIT 0, 30' at line 1 i changed the code a bit and i didnt get an error, but i got an empty list //-------------------------------- //Talking With the DB //-------------------------------- $time = (time()-86400); $info = mysql_query ("SELECT * FROM ibf_members WHERE last_activity > $time ORDER BY members_display_name"); Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 ah ha! i got it...the query won't accept time() but will accept a variable...AND i need to move the closing '}' from the while fucntion to the end of the whole script...now it works! thanks ya'll it always helps to bounce ideas off of someone else. Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted November 23, 2008 Share Posted November 23, 2008 It actually may accept the time() string, but look at yours...it has a space between the parenthesis Quote Link to comment Share on other sites More sharing options...
MrLarkins Posted November 23, 2008 Author Share Posted November 23, 2008 I saw that too, but it wasn't a space...it just looks like a space. it makes the list, but doesn't change the colors...i'll work on that part tomorrow...thanks for the help! working: PAST 7 DAYS http://www.oskgaming.com/forums/visitors7.php PAST 30 DAYS http://www.oskgaming.com/forums/visitors30.php Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted November 24, 2008 Share Posted November 24, 2008 Now you can add a mysql_num_rows to count the number of users online good work getting your script to work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.