Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-27-2008, 11:57 AM   PM User | #1
Jon W
Regular Coder

 
Join Date: Jan 2008
Posts: 334
Thanks: 9
Thanked 0 Times in 0 Posts
Jon W is an unknown quantity at this point
See whos Online

Hello, I'm back yet again with another question. Since you guys was so helpful the last time I figure you guys could probably help this time. Its simple really what I'm doing, but I can't seem to figure out why my problem is with this. Ok so the goal here is to make a script to check and see whos online. How that works is in the database whenever someone logs in the column in the database turns from 0 to 1, which means that they are online. The problem here that I'm having is making a script that whenever it turns to 1 it will add to up and up. For example, one player was online and then another person logged it and that would make it two. I thought at first this should be fairly simple, which shortly after messing around with this realizeing how bad my knowledge really is in PHP. So this is what I tried.


PHP Code:

<?php 

$con 
mysql_connect('localhost','username','password');
if(!
$con) {
die(
'Server Error: ' mysql_error());
}

mysql_select_db('characters'$con);

$online_players mysql_query("SELECT FROM characters WHERE online = '1'") or die('Database Error: ' mysql_error());

$players_online mysql_num_rows($online);

?>
But whenever I tried that I got the following error:

Server Error: 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 'FROM characters WHERE online ='1'' at line 1
Jon W is offline   Reply With Quote
Old 09-27-2008, 12:27 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
SELECT FROM characters WHERE online = '1'"
select WHAT from characters ?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:36 AM.


Advertisement
Log in to turn off these ads.