Jump to content

What have i done wrong???


jkemr

Recommended Posts

Hi guys take alook at this php code for me and tell me if i have gone wrong its a whos online to work with x7chat but it wont work just shows up this error > Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/eastmanc/public_html/whosonline.php on line 20

 

Here is the code

function who_is_in_chat(){

// MySql Information

$user = "eastmanc_jk"; // Your MySql username

$pass = "mypassword"; // Your MySql password

$db = "eastmanc_chat"; // Your MySql Database

$prefix = "x7chat2_"; // Your table prefix

$expire_time = 30; // The amount of seconds that users can be idle before they are considered offline

// This value is setable in the X7 Chat admin panel, you must also set it here.

// If the values do not match then the scripts may be inaccurate.

// No more editing required

 

mysql_connect("localhost",$user,$pass);

mysql_select_db($db);

 

$exp_time = time()-$expire_time;

$q = mysql_query("DELETE FROM {$prefix}online WHERE time

$q = mysql_query("SELECT username FROM {$prefix}online");

$results = array();

while($row = mysql_fetch_row($q))

$results[] = $row[0];

return $results;

}

 

function list_totals(){

echo count(who_is_in_chat());

}

 

function list_members($sep=", "){

$online = who_is_in_chat();

echo implode($sep,$online);

}

 

?>

Thanks for any info guys JK

Link to comment
Share on other sites

<?php

 

$dbh=mysql_connect ("localhost", "eastmanc_jk", "password") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("eastmanc_chat", $dbh);

 

$usernames = array();

$exp = time()-500;

$count = 0;

$users = mysql_query("SELECT username, roomname FROM X7Chat_online WHERE time>'$exp'");

 

$userlist = "Empty";

 

while ($allusers = mysql_fetch_array($users))

{

$theusers = count($allusers['username']);

$usernames[] = "$allusers[username]";

if ($theusers > 0)

{

$userlist = implode(', ', $usernames);

$count++;

}

 

}

 

mysql_close($dbh);

 

echo "Currently online the Chat Room

";

 

echo $userlist;

 

?>

 

tryed this one say error in line 13 thats this one ?? while ($allusers = mysql_fetch_array($users))

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...