Jump to content

Simple Script, or so I thought


MrLarkins

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/133850-simple-script-or-so-i-thought/
Share on other sites

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);
?>

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?

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

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");  

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.

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.