Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-01-2007, 09:03 PM   #1 (permalink)
In The Zone
 
╬Switch╬'s Avatar
 
Join Date: Nov 2006
Posts: 280
Exclamation PHP Live Counter problem!!


I got this code from webdesign.org it does work,
Code:
<? 
//DBase Name: 
$opt_connected_cfgbase = "base"; 
//Username : 
$opt_connected_cfguser = "user"; 
//PassWord : 
$opt_connected_cfgpass = "pass"; 
//Path : 
$opt_connected_cfghote = "localhost"; 
// Amout of time to consider a user active 
$nb_connected_connexion=300; // 5 minutes 
 
// Connexion to the database 
$base_connected=mysql_connect($opt_connected_cfghote, $opt_connected_cfguser,$opt_connected_cfgpass); 
if (!$base_connected) 
{ 
("<center>Error connecting to the Database </center>"); 
exit(); 
} 
 
// Database selecting 
if (! mysql_select_db("$opt_connected_cfgbase",$base_connected)) 
{ 
mysql_close($base_connected); 
print("<center>Error connecting to the Database</center>"); 
exit(); 
} 
 
// time 
$time_connected=date("U"); 
 
// Get IP 
$ip_connected=$REMOTE_ADDR; 
 
// Search IP in the DB 
$query_connected="select * from nb_connected where ip='$ip_connected'"; 
$result_connected=@mysql_query($query_connected,$base_connected); 
 
if (!$result_connected) 
{ 
mysql_close($base_connected); 
print("<center>Could not execute request </center>"); 
exit(); 
} 
 
$nb_connected=@mysql_num_rows($result_connected); 
if ($nb_connected) 
{ 
// Update the connexion 
$query_connected="update nb_connected set time='$time_connected' where ip='$ip_connected'"; 
$result_connected=@mysql_query($query_connected,$base_connected); 
} 
else 
{ 
// Create connexion 
$query_connected="insert into nb_connected (ip, time) values ('"; 
$query_connected.=$ip_connected; 
$query_connected.="', '"; 
$query_connected.=$time_connected; 
$query_connected.="')"; 
$result_connected=@mysql_query($query_connected,$base_connected); 
} 
 
// Calculate maximum time of connexion 
$time_max_connected=$time_connected-$nb_connected_connexion; 
 
// Deleting Maximum time connexion from DB 
$query_connected="delete from nb_connected where time<'$time_max_connected'"; 
$result_connected=@mysql_query($query_connected,$base_connected); 
 
// Close connexion to DB 
mysql_close($base_connected); 
?>
But it is displayed along with the following error:
Notice: Undefined variable: REMOTE_ADDR in d:\web\tools\easyphp\www\counter\index.php on line 35

Can anyone help me get it right
__________________
There are 10 types of people. Those who understand binary and those who don’t…

Last edited by ╬Switch╬; 01-01-2007 at 09:10 PM.
╬Switch╬ is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 02-01-2007, 08:15 PM   #2 (permalink)
Right Off the Assembly Line
 
Join Date: May 2005
Location: INDIA
Posts: 24
Default Re: PHP Live Counter problem!!

Hello there,

Use,

$_SERVER['REMOTE_ADDR']

instead of

REMOTE_ADDR

Hope this helps you out.

Regards
Utsav HAnda
__________________
Ur\'s
Utsav Handa {:-)
utsavhanda is offline  
Old 03-01-2007, 06:27 PM   #3 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: PHP Live Counter problem!!

This needs a MySQL database. Hope you have created one and connected with this! However, I have seen simpler PHP counters that don't need a DB. They are lighter on the system.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 07-01-2007, 09:13 AM   #4 (permalink)
In The Zone
 
╬Switch╬'s Avatar
 
Join Date: Nov 2006
Posts: 280
Default Re: PHP Live Counter problem!!

@utsav handa:
Ill try that.Thanks.
__________
@tuxfan
The couneter I have above counts the number of people online at that instant.
The ones you mention (ones which are made using text files) count number of visits to a page.
__________________
There are 10 types of people. Those who understand binary and those who don’t…

Last edited by ╬Switch╬; 07-01-2007 at 09:13 AM. Reason: Automerged Doublepost
╬Switch╬ is offline  
Old 08-01-2007, 04:47 PM   #5 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: PHP Live Counter problem!!

Ah ok That one is also a useful indicator.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 14-01-2007, 12:21 PM   #6 (permalink)
In The Zone
 
╬Switch╬'s Avatar
 
Join Date: Nov 2006
Posts: 280
Default Re: PHP Live Counter problem!!

@utsav handa:
Thankx
$_SERVER['REMOTE_ADDR'] worked!!
__________________
There are 10 types of people. Those who understand binary and those who don’t…
╬Switch╬ is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Tenida
- by Charan
- by abhidev
- by Sujeet
- by Sarath

Advertisement




All times are GMT +5.5. The time now is 09:44 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2