jkemr Posted September 30, 2008 Share Posted September 30, 2008 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 More sharing options...
James Posted September 30, 2008 Share Posted September 30, 2008 hmm.. is your database name x7chat2_ or x7chat2 ?? Studiio - All-In-One Radio Communication Platform SMS | Phone Calls | Social Media | Content Link to comment Share on other sites More sharing options...
jkemr Posted September 30, 2008 Author Share Posted September 30, 2008 hmm.. is your database name x7chat2_ or x7chat2 ?? Datbase name is eastmanc_chat prefix is x7chat2_ Link to comment Share on other sites More sharing options...
James Posted September 30, 2008 Share Posted September 30, 2008 Hmm i see no error.. but where do you put in your database host like mysql.something.com? Or is it hosted localhost? Studiio - All-In-One Radio Communication Platform SMS | Phone Calls | Social Media | Content Link to comment Share on other sites More sharing options...
jkemr Posted September 30, 2008 Author Share Posted September 30, 2008 Hmm i see no error.. but where do you put in your database host like mysql.something.com? Or is it hosted localhost? yes localhost m8 i just been doing some reading might be coz i dont have GD Library installed whatever that is lol Link to comment Share on other sites More sharing options...
James Posted September 30, 2008 Share Posted September 30, 2008 Oh.. that may be the problem. I cant see any errors in the code.. Studiio - All-In-One Radio Communication Platform SMS | Phone Calls | Social Media | Content Link to comment Share on other sites More sharing options...
jkemr Posted September 30, 2008 Author Share Posted September 30, 2008 its showing whos online but as that error above?? mmmm Think i will have to play with the code its only looking in datebase see whos online and reports back should be easy?? i hope lol think ill make new code Link to comment Share on other sites More sharing options...
jkemr Posted September 30, 2008 Author Share Posted September 30, 2008 <?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 More sharing options...
jkemr Posted September 30, 2008 Author Share Posted September 30, 2008 Got it working now guys never mind Thanks JK Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.