Re: [PHP] PHP Counter?
On Mon, 27 Sep 2004 11:29:34 +0200, Nick Wilson <[EMAIL PROTECTED]> wrote: * and then raditha dissanayake declared >>These counters are pretty much useless at gauging web traffic. you would >>be better off using log analysis tool. >> >> > >Who said anything about web traffic? ;-) > > which in turn means your mail wasn't detailed enough. :-) Nice try. But come one mate, you just *assumed* - you dont have to know the purpose of the script to anwser the question... It does tend to be rather helpful. I have no clue what you're trying to do, which makes it hard to help you do it. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Counter?
Nick Wilson wrote: Hi all, I have a script that at the present just outputs '$count .''' after each iteration of a foreach() loop. I have set implicit_flush so that this works. That's clearly monkey poo though eh? :-) Do I have to get into unkown waters and try and make PHP talk to JS to achieve a kind of 'hit counter' like effect or is there some easier way? ::explanation It should print the $count var after each iteration *replacing* the last $count Im stumped. A little guidance would be much appreciated... Either JS or Refresh header with some timeout. With JS you can use a input textbox styled to not have any borders. Refresh header will refresh the whole page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Counter?
Hi all, I have a script that at the present just outputs '$count .''' after each iteration of a foreach() loop. I have set implicit_flush so that this works. That's clearly monkey poo though eh? :-) Do I have to get into unkown waters and try and make PHP talk to JS to achieve a kind of 'hit counter' like effect or is there some easier way? ::explanation It should print the $count var after each iteration *replacing* the last $count Im stumped. A little guidance would be much appreciated... -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Counter on HTML Page
Astrum! I've never used GD or ImageMagick before.. can you guide me to any tutorial, script, reference.. something upon the same that can help me out? Thanks, Dominor! PHPSpooky > Write a PHP script that makes the image for you using GD or Imagemagick, > then just include it like any other image: > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Counter on HTML Page
Astrum Et Securis! I don't want to use iFrames.. is there any other way? I want to use my own php counter with lil information.. which updates the database on page load incrementing the counter and catching the few Server Variables.. and just display the Hits on that page. However.. that page is an HTML page.. not a php page. Is there any solution to this? Dominor! PHPSpooky ~ "Every man has a right to fulfill his own Will without being afraid that it may interfere with that of others; for if he is in his proper path, it is the fault of others if they interfere with him. Do what thy wilt shall be the whole of the Law! Love is the Law, Love under Will" - Aleister Crowley, "Magick without Tears" Rahul Sitaram 'fearless' Johari {rahulsjohari.com} Shining Star Productions [Italy] The Internet Architects Group [USA] NKB Software Solutions (P) Ltd. [India] ~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Counter on HTML Page
>I've never used GD or ImageMagick before.. can you guide me to any >tutorial, script, reference.. something upon the same that can help me >out? Can you -please- do some of your own legwork once in a while? http://www.google.com/search?q=imagemagick+tutorial http://www.google.com/search?q=gd+php+tutorial - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Counter on HTML Page
PHPSpooky wrote: Astrum Et Securis! I don't want to use iFrames.. is there any other way? I want to use my own php counter with lil information.. which updates the database on page load incrementing the counter and catching the few Server Variables.. and just display the Hits on that page. However.. that page is an HTML page.. not a php page. Is there any solution to this? Write a PHP script that makes the image for you using GD or Imagemagick, then just include it like any other image: -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Counter on HTML Page
Astrum! Once in a while.. Sure. Dominor! PHPSpooky > Can you -please- do some of your own legwork once in a while? > > http://www.google.com/search?q=imagemagick+tutorial > http://www.google.com/search?q=gd+php+tutorial > > - > michal migurski- contact info and pgp key: > sf/cahttp://mike.teczno.com/contact.html > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counter has gremlins
I believe this is a concurrency problem... 2 PHP scripts can run at the same time and the problem is that your first script gets as far as the unlink thus deleting the file. Then the 2nd script is ran (at the same time) and trys to open the file which doesn't exist, therefore it reads a num of 0. Then control returns to script 1 which saves the number num (which is a valid count), and finish... Script 2 continues and saves the num 0, and therefore your counter gets reset. Its all a problem of concurrency and the fact that more than one thing can happen at a time. There are a few solutions. 1) Use MySQL or another database which limits reading/writing to the data so that problems like this do not occur. 2) Use a flocking method which locks the file between the reading and writing so that no other script can interfeare... I'm unsure on how good this method is with PHP, so I suggest the first. Andrew - Original Message - From: "Brian V Bonini" <[EMAIL PROTECTED]> To: "PHP Lists" <[EMAIL PROTECTED]> Sent: Tuesday, February 18, 2003 12:45 AM Subject: [PHP] Counter has gremlins > I have this basic counter: > > $counterFile = "./counter.txt"; > function displayCounter($counterFile) { > global $counted; > $fp = fopen($counterFile, 'rw'); > $num= fgets($fp,7); > if (!$counted) { > $num+= 1; > unlink("$counterFile"); > exec("echo $num > $counterFile"); > } > print "Visitor #$num"; > } > if (!file_exists($counterFile)) { > exec("echo 1 > $counterFile"); > } > displayCounter($counterFile); > > ?> > > Works like a charm but every so often for no apparent reason it resets > to 0. > > Anyone see anything wrong here to cause that? > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counter has gremlins
You could be having problems with multiple users, if two visitors come at the same time file locking problems come into play, one script could unlink the file at the same time another script tries to open it resulting in an empty file. A database would be a better way to do this, but assuming you want to stick with a text based counter instead of using rw and incrementing the count you might consider opening the file in append mode and writing a character to the file, then when you want to find out how many people have visited count the lines in the file. Using file based operations where you may have more than one user operating on one file at the same time can get tricky so like I said consider a database. Jason Mon, 2003-02-17 at 17:45, Brian V Bonini wrote: > I have this basic counter: > > $counterFile = "./counter.txt"; > function displayCounter($counterFile) { > global $counted; > $fp = fopen($counterFile, 'rw'); > $num= fgets($fp,7); > if (!$counted) { > $num+= 1; > unlink("$counterFile"); > exec("echo $num > $counterFile"); > } > print "Visitor #$num"; > } > if (!file_exists($counterFile)) { > exec("echo 1 > $counterFile"); > } > displayCounter($counterFile); > > ?> > > Works like a charm but every so often for no apparent reason it resets > to 0. > > Anyone see anything wrong here to cause that? > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Counter has gremlins
I have this basic counter: $counterFile"); } print "Visitor #$num"; } if (!file_exists($counterFile)) { exec("echo 1 > $counterFile"); } displayCounter($counterFile); ?> Works like a charm but every so often for no apparent reason it resets to 0. Anyone see anything wrong here to cause that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter question
ahuh "Jason Wong" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thursday 13 February 2003 20:23, Dan Rossi wrote: > > i mean can u output the counter to the screen with php ? like 1 wait a few > > seconds 2 wait a few more seconds 3 etc .., atm it will go through the loop > > first then output > > In theory yes. But it depends on your webserver. Search the archives. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > Nihilism should commence with oneself. > */ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter question
On Thursday 13 February 2003 20:23, Dan Rossi wrote: > i mean can u output the counter to the screen with php ? like 1 wait a few > seconds 2 wait a few more seconds 3 etc .., atm it will go through the loop > first then output In theory yes. But it depends on your webserver. Search the archives. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Nihilism should commence with oneself. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter question
i mean can u output the counter to the screen with php ? like 1 wait a few seconds 2 wait a few more seconds 3 etc .., atm it will go through the loop first then output -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 13, 2003 11:12 PM To: electroteque Cc: [EMAIL PROTECTED] Subject: Re: [PHP] counter question You might still have a buffer at apache or system level, you can try to output spaces or coments, but I'm not sure something like this is possible in flash electroteque wrote: >hi guys i am trying to increment a counter echoed out to the screen to be >used for flash > >for ($i=0; $i < 10; $i++) { > //$string = $i; > echo "varText=$i&"; > flush(); > ob_flush(); > sleep(1); >} > >i cant seem to get each one out at a time , it will go through it then >output at the end ?? > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter question
You might still have a buffer at apache or system level, you can try to output spaces or coments, but I'm not sure something like this is possible in flash electroteque wrote: hi guys i am trying to increment a counter echoed out to the screen to be used for flash for ($i=0; $i < 10; $i++) { //$string = $i; echo "varText=$i&"; flush(); ob_flush(); sleep(1); } i cant seem to get each one out at a time , it will go through it then output at the end ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] counter question
hi guys i am trying to increment a counter echoed out to the screen to be used for flash for ($i=0; $i < 10; $i++) { //$string = $i; echo "varText=$i&"; flush(); ob_flush(); sleep(1); } i cant seem to get each one out at a time , it will go through it then output at the end ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter freezes whole site!
> This code is supposed to write a 24h cookie at first visit, and then > checks for it at every refresh, if the cookie doesnt exist, it increases a > counter on the DB. Simple, right? Then why did it stop working out of the > blue? It loops on the refresh, keeps thinking the cookie is not active, so > it keeps adding +1 to the counter. What am i doing wrong? How can i fix > it? > if ($pvisita == '1') { Try if($_COOKIE['pvisita'] == 1) instead... > break; > } else { > > include ('databaseinfo.txt'); > $ligacao=mysql_connect($h, $u, $p) or die("Erro ao aceder a MySQL"); > @mysql_select_db($DBname) or die("Unable to select database " . $DBname); > $resultado = mysql_query ("select * from counttable where id='0'"); > > if ($resultado) { > $registo = mysql_fetch_array($resultado); > $id = $registo["ID"]; > $contador = $registo["contador"]; > $contador = $contador + 1; > $resultado2 = mysql_query ("update counttable set contador='$contador' > where id='0'"); > setcookie("pvisita", "1", time() + 86400); > header("Location: $PHP_SELF"); > > }else{ > print ("não há registos"); > break; > } Also, for the rest of that, it'd be easier to just issue one query such as: Update countable set contador = contador + 1 where id = 0 ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] counter freezes whole site!
Hi, I am having a serious problem on my site. It was working fine until a day ago, when it simply freezes. After i made a few checks i realized it loops on this code. I tried everything but i cant understand why and i am going crazy trying to figure it out! This code is supposed to write a 24h cookie at first visit, and then checks for it at every refresh, if the cookie doesnt exist, it increases a counter on the DB. Simple, right? Then why did it stop working out of the blue? It loops on the refresh, keeps thinking the cookie is not active, so it keeps adding +1 to the counter. What am i doing wrong? How can i fix it? oh, this code is right at the top of my main page. Thanks! if ($pvisita == '1') { break; } else { include ('databaseinfo.txt'); $ligacao=mysql_connect($h, $u, $p) or die("Erro ao aceder a MySQL"); @mysql_select_db($DBname) or die("Unable to select database " . $DBname); $resultado = mysql_query ("select * from counttable where id='0'"); if ($resultado) { $registo = mysql_fetch_array($resultado); $id = $registo["ID"]; $contador = $registo["contador"]; $contador = $contador + 1; $resultado2 = mysql_query ("update counttable set contador='$contador' where id='0'"); setcookie("pvisita", "1", time() + 86400); header("Location: $PHP_SELF"); }else{ print ("não há registos"); break; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter problem
Hi Mike, I tried the first script you posted on the NG. This is what happens when I copy and paste your script: The formbox appears. I insert a number. I click submit. The number reverts back to 0. The URL script that you sent me works fine. I'm using MS Win 98/ Apache / PHP 4 Please advise if you get a chance if you know why I can't get this script to work. Thank you. Tony Ritter --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter problem
I won't keep it up long... but go here... you will see it works... http://rc.mikeathome.net:8080/test/index.php *** REPLY SEPARATOR *** On 04/01/2003 at 7:17 PM Anthony Ritter wrote: >Michael J. Pawlowsky wrote in message: > >> This also works with the ternary operator... >. > >No dice Michael. > >I treid both your scripts. > >The formbox comes up. >I enter a number. >I hit submit. >The box clears out the entered number without any message whether the >number >was too high or too low or correct. > >Nothing with the counter as well... > >Please advise. > >TR > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter problem
Michael J. Pawlowsky wrote in message: > This also works with the ternary operator... . No dice Michael. I treid both your scripts. The formbox comes up. I enter a number. I hit submit. The box clears out the entered number without any message whether the number was too high or too low or correct. Nothing with the counter as well... Please advise. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter problem
This also works with the ternary operator... I don't think it likes the ++ because it doesn't know the type yet. $numtoguess) $message="Your guess was too high."; else $message="That is the correct number."; if(isset($_POST['guess'])) $guess=(int)$_POST['guess']; else $guess=0; print_r($_POST); ?> Guess number: Type your guess here: *** REPLY SEPARATOR *** On 04/01/2003 at 6:40 PM Anthony Ritter wrote: >The following script is found in Matt Zandstra's book on PHP (Sams) on >page >160. > >He's explaining forms with PHP and has hard coded a value - 42. > >He also is explaining a hidden fleld where the user can submit the number >and each time the user hits submit in the formbox, the counter will >register >the total number of guesses. > >However, after running this script and submitting the number, I get: > >Guess number: 0 \\\"\\ > >submit again and... > >Guess number: 0 \\"", etc... > >instead of: > >Guess number: 1 >Guess numver : 2 >etc... > >Thanking all in advance. >Tony Ritter >.. > > >$numtoguess=42; >$num_tries=(isset($num_tries)) ? $num_tries++ : 0; >$message=""; >if(!isset($guess)) >$message="Welcome to the guessing machine"; >elseif ($guess<$numtoguess) >$message="Your guess was too low."; >elseif ($guess>$numtoguess) >$message="Your guess was too high."; >else >$message="That is the correct number."; >$guess=(int)$guess; >?> > > > > > >Guess number: > >Type your guess here: > >"> > > > > > > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter problem
Use this... enjoy $numtoguess) $message="Your guess was too high."; else $message="That is the correct number."; if(isset($_POST['guess'])) $guess=(int)$_POST['guess']; else $guess=0; print_r($_POST); ?> Guess number: Type your guess here: *** REPLY SEPARATOR *** On 04/01/2003 at 6:40 PM Anthony Ritter wrote: >The following script is found in Matt Zandstra's book on PHP (Sams) on >page >160. > >He's explaining forms with PHP and has hard coded a value - 42. > >He also is explaining a hidden fleld where the user can submit the number >and each time the user hits submit in the formbox, the counter will >register >the total number of guesses. > >However, after running this script and submitting the number, I get: > >Guess number: 0 \\\"\\ > >submit again and... > >Guess number: 0 \\"", etc... > >instead of: > >Guess number: 1 >Guess numver : 2 >etc... > >Thanking all in advance. >Tony Ritter >.. > > >$numtoguess=42; >$num_tries=(isset($num_tries)) ? $num_tries++ : 0; >$message=""; >if(!isset($guess)) >$message="Welcome to the guessing machine"; >elseif ($guess<$numtoguess) >$message="Your guess was too low."; >elseif ($guess>$numtoguess) >$message="Your guess was too high."; >else >$message="That is the correct number."; >$guess=(int)$guess; >?> > > > > > >Guess number: > >Type your guess here: > >"> > > > > > > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] counter problem
The following script is found in Matt Zandstra's book on PHP (Sams) on page 160. He's explaining forms with PHP and has hard coded a value - 42. He also is explaining a hidden fleld where the user can submit the number and each time the user hits submit in the formbox, the counter will register the total number of guesses. However, after running this script and submitting the number, I get: Guess number: 0 \\\"\\ submit again and... Guess number: 0 \\"", etc... instead of: Guess number: 1 Guess numver : 2 etc... Thanking all in advance. Tony Ritter .. $numtoguess) $message="Your guess was too high."; else $message="That is the correct number."; $guess=(int)$guess; ?> Guess number: Type your guess here: "> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counter ?
www.hotscripts.com Follow your nose. Also, Richard's right. This list is for technical problems. If you can't find it in a search engine, then and only then, ask here. www.google.com is your god - amen - Original Message - From: "CMS" <[EMAIL PROTECTED]> To: "PHP General" <[EMAIL PROTECTED]> Sent: Saturday, April 27, 2002 7:25 AM Subject: [PHP] Counter ? I am looking for a php counter, that can do this: ___ Total Visits: 8,585,230 Visits Today: 2,521 Today Date: Friday Jan 1, 2002 __ And the kicker, to have the ability to put this counter, on any page, to have it count that page sperate Thanks- Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counter ?
This list is to answer questions for programming problems. Write the script yourself. If it fails, post the code and we'll be glad to help. sheesh - Original Message - From: CMS <[EMAIL PROTECTED]> To: PHP General <[EMAIL PROTECTED]> Sent: Friday, April 26, 2002 4:25 PM Subject: [PHP] Counter ? I am looking for a php counter, that can do this: ___ Total Visits: 8,585,230 Visits Today: 2,521 Today Date: Friday Jan 1, 2002 __ And the kicker, to have the ability to put this counter, on any page, to have it count that page sperate Thanks- Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Counter ?
I am looking for a php counter, that can do this: ___ Total Visits: 8,585,230 Visits Today: 2,521 Today Date: Friday Jan 1, 2002 __ And the kicker, to have the ability to put this counter, on any page, to have it count that page sperate Thanks- Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter for HIGH traffic site
On Mon, 8 Apr 2002, Matthew Walker wrote: > You definitely want to use MySQL for this. Ignore all those people who > recommended text file DBs. They are /SLOW/. MySQL is very very fast. I'll echo this. MySQL is hyperoptimized for this sort of transaction. It already has the databases open so that you don't have to deal with the overhead of the filesystem locating and opening files. And it solves the locking issues on its own. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter for HIGH traffic site
What is wrong with simply using the log files. Seems to me this is a lot of excess overhead for very little data. A low end log analyzer will provide this same info and much more. (and possibly free... such as HTTP Analyze - http://www.netstore.de/Supply/http-analyze/) olinux --- "SHEETS,JASON (Non-HP-Boise,ex1)" <[EMAIL PROTECTED]> wrote: > Make sure you are locking the file if you do this, > > With a high amount of traffic text based counters > don't usually work too > well because you have to deal with contention, what > if two users view a page > at the same time, you will run into a corrupt or > inaccurate number. > > If you do file locking do you display an error > asking them to refresh or do > you handle it some other way? This becomes apparent > especially with higher > traffic sites like he was talking about. > > You may well be best off using a database, either > that or invest some > serious thought into how you are going to handle > multiple clients loading > pages. > > Jason > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 08, 2002 12:56 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] counter for HIGH traffic site > > > If it should be fast, > avoid using mysql, just write a file with your > number, > if there´s a new request, get your number, add one > and write it back. > So you avoid mysql-"SQL parsing", opening Database, > searching data, > send to process, php putting in var... > just open, read, add, write, close > HTH Oliver > At 08.04.2002 14:32, you wrote: > > > >You might also want to setup the table your > updating the hits in > >as a HASH type table which runs completely in RAM, > and as a result > >is extremely fast. The only obvious downside, is > the data (or hits in this > >case) > >are lost on reboot. > > > >Adam Voigt > >[EMAIL PROTECTED] > > > >On Mon, 8 Apr 2002 09:41:39 -0700, Jim Lucas [php] > <[EMAIL PROTECTED]> > wrote: > > > as long as you are only inserting information > into the mysql db on each > > page > > > load, then you shouldn't have a problem. make > sure you keep you > indecies > > > down to a minimum. > > > > > > Jim Lucas > > > > > > - Original Message - > > > From: "Craig Westerman" > <[EMAIL PROTECTED]> > > > To: "php-general-list" > <[EMAIL PROTECTED]> > > > Sent: Saturday, April 06, 2002 11:57 PM > > > Subject: [PHP] counter for HIGH traffic site > > > > > > > > > > I'm needing counter for site that receives 60 > to 80 hits a minute. > Many I > > > > have tried cause excessive server load and > need to be deactivated or > they > > > > lose data and return to zero without warning. > All tried so far have > been > > > > written in Perl. > > > > > > > > Anyone here know of a PHP counter that would > handle HIGH traffic with > > > little > > > > added server load? Would using MySQL to store > count be of any benifit? > > > > > > > > Thanks > > > > > > > > Craig ><> > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: > http://www.php.net/unsub.php > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter for HIGH traffic site
You definitely want to use MySQL for this. Ignore all those people who recommended text file DBs. They are /SLOW/. MySQL is very very fast. To show you a small sample of how fast, here's the debug data from one of my scripts, showing how long the page took to generate, and how many queries were run. The queries consist of the same kind you would be using. Debug Data This page was generated in 0.030305027961731 seconds. 9 queries executed. Matthew Walker Ecommerce Project Manager Mountain Top Herbs -Original Message- From: Craig Westerman [mailto:[EMAIL PROTECTED]] Sent: Saturday, April 06, 2002 11:58 PM To: php-general-list Subject: [PHP] counter for HIGH traffic site I'm needing counter for site that receives 60 to 80 hits a minute. Many I have tried cause excessive server load and need to be deactivated or they lose data and return to zero without warning. All tried so far have been written in Perl. Anyone here know of a PHP counter that would handle HIGH traffic with little added server load? Would using MySQL to store count be of any benifit? Thanks Craig ><> [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] counter for HIGH traffic site
Make sure you are locking the file if you do this, With a high amount of traffic text based counters don't usually work too well because you have to deal with contention, what if two users view a page at the same time, you will run into a corrupt or inaccurate number. If you do file locking do you display an error asking them to refresh or do you handle it some other way? This becomes apparent especially with higher traffic sites like he was talking about. You may well be best off using a database, either that or invest some serious thought into how you are going to handle multiple clients loading pages. Jason -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 12:56 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] counter for HIGH traffic site If it should be fast, avoid using mysql, just write a file with your number, if there´s a new request, get your number, add one and write it back. So you avoid mysql-"SQL parsing", opening Database, searching data, send to process, php putting in var... just open, read, add, write, close HTH Oliver At 08.04.2002 14:32, you wrote: > >You might also want to setup the table your updating the hits in >as a HASH type table which runs completely in RAM, and as a result >is extremely fast. The only obvious downside, is the data (or hits in this >case) >are lost on reboot. > >Adam Voigt >[EMAIL PROTECTED] > >On Mon, 8 Apr 2002 09:41:39 -0700, Jim Lucas [php] <[EMAIL PROTECTED]> wrote: > > as long as you are only inserting information into the mysql db on each > page > > load, then you shouldn't have a problem. make sure you keep you indecies > > down to a minimum. > > > > Jim Lucas > > > > - Original Message - > > From: "Craig Westerman" <[EMAIL PROTECTED]> > > To: "php-general-list" <[EMAIL PROTECTED]> > > Sent: Saturday, April 06, 2002 11:57 PM > > Subject: [PHP] counter for HIGH traffic site > > > > > > > I'm needing counter for site that receives 60 to 80 hits a minute. Many I > > > have tried cause excessive server load and need to be deactivated or they > > > lose data and return to zero without warning. All tried so far have been > > > written in Perl. > > > > > > Anyone here know of a PHP counter that would handle HIGH traffic with > > little > > > added server load? Would using MySQL to store count be of any benifit? > > > > > > Thanks > > > > > > Craig ><> > > > [EMAIL PROTECTED] > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter for HIGH traffic site
If it should be fast, avoid using mysql, just write a file with your number, if there´s a new request, get your number, add one and write it back. So you avoid mysql-"SQL parsing", opening Database, searching data, send to process, php putting in var... just open, read, add, write, close HTH Oliver At 08.04.2002 14:32, you wrote: > >You might also want to setup the table your updating the hits in >as a HASH type table which runs completely in RAM, and as a result >is extremely fast. The only obvious downside, is the data (or hits in this >case) >are lost on reboot. > >Adam Voigt >[EMAIL PROTECTED] > >On Mon, 8 Apr 2002 09:41:39 -0700, Jim Lucas [php] <[EMAIL PROTECTED]> wrote: > > as long as you are only inserting information into the mysql db on each > page > > load, then you shouldn't have a problem. make sure you keep you indecies > > down to a minimum. > > > > Jim Lucas > > > > - Original Message - > > From: "Craig Westerman" <[EMAIL PROTECTED]> > > To: "php-general-list" <[EMAIL PROTECTED]> > > Sent: Saturday, April 06, 2002 11:57 PM > > Subject: [PHP] counter for HIGH traffic site > > > > > > > I'm needing counter for site that receives 60 to 80 hits a minute. Many I > > > have tried cause excessive server load and need to be deactivated or they > > > lose data and return to zero without warning. All tried so far have been > > > written in Perl. > > > > > > Anyone here know of a PHP counter that would handle HIGH traffic with > > little > > > added server load? Would using MySQL to store count be of any benifit? > > > > > > Thanks > > > > > > Craig ><> > > > [EMAIL PROTECTED] > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] counter for HIGH traffic site
You might also want to setup the table your updating the hits in as a HASH type table which runs completely in RAM, and as a result is extremely fast. The only obvious downside, is the data (or hits in this case) are lost on reboot. Adam Voigt [EMAIL PROTECTED] On Mon, 8 Apr 2002 09:41:39 -0700, Jim Lucas [php] <[EMAIL PROTECTED]> wrote: > as long as you are only inserting information into the mysql db on each page > load, then you shouldn't have a problem. make sure you keep you indecies > down to a minimum. > > Jim Lucas > > - Original Message - > From: "Craig Westerman" <[EMAIL PROTECTED]> > To: "php-general-list" <[EMAIL PROTECTED]> > Sent: Saturday, April 06, 2002 11:57 PM > Subject: [PHP] counter for HIGH traffic site > > > > I'm needing counter for site that receives 60 to 80 hits a minute. Many I > > have tried cause excessive server load and need to be deactivated or they > > lose data and return to zero without warning. All tried so far have been > > written in Perl. > > > > Anyone here know of a PHP counter that would handle HIGH traffic with > little > > added server load? Would using MySQL to store count be of any benifit? > > > > Thanks > > > > Craig ><> > > [EMAIL PROTECTED] > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counter for HIGH traffic site
as long as you are only inserting information into the mysql db on each page load, then you shouldn't have a problem. make sure you keep you indecies down to a minimum. Jim Lucas - Original Message - From: "Craig Westerman" <[EMAIL PROTECTED]> To: "php-general-list" <[EMAIL PROTECTED]> Sent: Saturday, April 06, 2002 11:57 PM Subject: [PHP] counter for HIGH traffic site > I'm needing counter for site that receives 60 to 80 hits a minute. Many I > have tried cause excessive server load and need to be deactivated or they > lose data and return to zero without warning. All tried so far have been > written in Perl. > > Anyone here know of a PHP counter that would handle HIGH traffic with little > added server load? Would using MySQL to store count be of any benifit? > > Thanks > > Craig ><> > [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] counter for HIGH traffic site
I'm needing counter for site that receives 60 to 80 hits a minute. Many I have tried cause excessive server load and need to be deactivated or they lose data and return to zero without warning. All tried so far have been written in Perl. Anyone here know of a PHP counter that would handle HIGH traffic with little added server load? Would using MySQL to store count be of any benifit? Thanks Craig ><> [EMAIL PROTECTED]
RE: [PHP] Counter
It's very simple - at the top of every page, have a routine that opens a text file, reads the number inside it into a variable, adds one, and writes it back out again. If the text file doesn't exist, create it. Psuedocode: if (file exists) { open file for reading; read contents into $counter; increase $counter by 1; } else { set $counter to 1; open file for writing; } write $counter to file; close file; print "you are visitor number $counter."; Look into fopen(), fread(), fwrite() and friends. Of course, it's now up to you to work out how you're going to count cached requests, search engine bots, link checkers, etc etc. Personally I reckon you're better off with this: Cheers Jon -Original Message- From: Mark Lo [mailto:[EMAIL PROTECTED]] Sent: 25 September 2001 16:50 To: php general Subject: [PHP] Counter Hi, I would like to know how to write a web page counter in PHP or Javascript. Thank You Mark Lo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** 'The information included in this Email is of a confidential nature and is intended only for the addressee. If you are not the intended addressee, any disclosure, copying or distribution by you is prohibited and may be unlawful. Disclosure to any party other than the addressee, whether inadvertent or otherwise is not intended to waive privilege or confidentiality' ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Counter
Hi, I would like to know how to write a web page counter in PHP or Javascript. Thank You Mark Lo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: php-counter
http://php.resourceindex.com/Complete_Scripts/Access_Counters/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php-counter
return $to_return; } return $to_return; } function _client_is_NS($s){ $to_return = FALSE; if(preg_match('~^Mozilla/([^.]+)\\.([\d.]+)([^ ]*).*?\\(([^;)]+)~i', $s, $a)){ if(strtolower($a[4]) == 'compatible') return FALSE; if(strtolower($a[4]) == 'macintosh'){ if(strpos($s, '68K')) $a[4] = 'Mac_68K'; elseif(strpos($s, 'PPC')) $a[4] = 'Mac_PPC'; } $to_return = array('mozilla' => $a[1] . "." . $a[2] . $a[3], 'major' => $a[1], 'minor' => $a[2], 'build' => $a[3]); if (strpos(' '.strtolower($a[4]),'win')){ // heading space added because specific return value of strpos() $to_return['platform'] = isset($this->windowses[strtolower($a[4])]) ? $this->windowses[strtolower($a[4])]:'win-unknown'; }else{ $to_return['platform'] = strtolower($a[4]); } return $to_return; } return $to_return; } function _client_is_Opera($s){ $to_return = FALSE; if(preg_match('~Mozilla/([^ ]+) \\(((Win|Windows|Mac_PowerPC|Mac_68000|Mac_68K|Mac_PPC)[^);]*).*Opera ([^.]+)\\.([\d.]+)([^; )]*)~i', $s, $a)){ $to_return = array('mozilla' => $a[1], 'major' => $a[4], 'minor' => $a[5], 'build' => $a[6]); if (strpos(' '.strtolower($a[2]),'win')){ $to_return['platform'] = isset($this->windowses[strtolower($a[2])]) ? $this->windowses[strtolower($a[2])]:'win-unknown'; }else{ $to_return['platform'] = strtolower($a[2]); } return $to_return; } if(preg_match('~Opera/([^.]+)\\.([\d.]+)([^; )]*) \\(((Win|Windows|Mac_PowerPC|Mac_68000|Mac_68K|Mac_PPC|OS/2|SUNOS|sunos 4|sunos 5|i86|irix|irix 6|irix 5|hp-ux|aix|aix1|aix2|aix3|aix4|linux|unix_system_v|ncr|reliantunix|bsd)[^); ]*)~i', $s, $a)){ $to_return = array('mozilla' => '', 'major' => $a[1], 'minor' => $a[2], 'build' => $a[3]); if (strpos(' '.strtolower($a[5]),'win')){ $to_return['platform'] = isset($this->windowses[strtolower($a[4])]) ? $this->windowses[strtolower($a[4])]:'win-unknown'; }else{ $to_return['platform'] = strtolower($a[4]); } return $to_return; } return $to_return; } } // -=-=-=-=-=--==-=-=-=--==-=-=-=-=-=-=-=-=-=-=-=-class ClientBrowser-=-=-==-=- // -=--==-=-=-=-=-=--==-=-=-=-=--==-=-MAIN--==-=-=--==-=--==-=-=-=-// $client = new ClientBrowser($HTTP_USER_AGENT); $page_name = $HTTP_GET_VARS['page']; $screen_width = $HTTP_GET_VARS['scr_w']+0; $screen_height = $HTTP_GET_VARS['scr_h']+0; $screen_color = $HTTP_GET_VARS['scr_c']+0; if (preg_match('/^([0-9\.]+)$/',$screen_width.''.$screen_height.''.$screen_colo r)==0){ exit; } if ($WEBSTATS_pages[$page_name]['collecting']==1){ // You must have the $WEBSTATS_pages array in the included file webstats.lib.php . Collecting shows if we collect info about this page db_connect(); $res = db_exec('SELECT COUNT(*) FROM webPages WHERE webpage_name="'.$page_name.'";'); list($is_there)=db_fetch_array($res); if ($is_there==0){ db_free_result($res); db_exec('INSERT INTO webPages VALUES("","'.$page_name.'");'); }else{ db_free_result($res); } $res = db_exec('SELECT webpage_id FROM webPages WHERE webpage_name="'.$page_name.'";'); list($webpage_id) = db_fetch_array($res); db_free_result($res); $sql_to_exec = "SELECT COUNT(*) FROM webStats WHERE webpage_id=$webpage_id AND os_name='".$client->platform. "' AND browser='".$client->browser." ".$client->major.".".$client->minor. "' AND screen_w=$screen_width AND screen_h=$screen_height AND screen_c=$screen_color;"; $res = db_exec($sql_to_exec); $is_there = 0; list($is_there) = db_fetch_array($res); db_free_result($res); if ($is_there==1){ $update_sql = "UPDATE webStats set counter=counter+1 WHERE webpage_id=$webpage_id AND os_name='".$client->platform. "' AND browser='".$client->browser." ".$client->major.".".$client->minor. "' AND screen_w=$screen_width AND screen_h=$screen_height AND screen_c=$screen_color;"; db_exec($update_sql); }else{ $insert_sql = "INSERT INTO webStats (webpage_id, os_name, browser, screen_w, screen_h, screen_c, counter) ". "VALUES($webpage_id,'".$client->platform."','".$client->browser." ".$client->major.".".$client->minor."',". "$screen_width, $screen_height, $screen_color, 1);"; db_exec($insert_sql); } } ?> Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: "Gert Mellak" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 22, 2001 6:49 PM Subject: [PHP] php-counter > hi! > > do you know an easy-to-use-php-counter, which uses mysql to store the data? > > gert > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php-counter
No, but I could throw one together in 10 minutes. Here is some 5 minute untested code to get you started where int count is in table counter. mailto:[EMAIL PROTECTED]\";>Administrator"; exit; } $count = mysql_result($dbq,0) echo "This page has been visited $count times!"; $query = "Update counter set count = count + 1"; if( !($dbq = mysql_query($query,$dblink))) { echo "Error updating database. Please Contact mailto:[EMAIL PROTECTED]\";>Administrator"; exit; } ?> Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: "Gert Mellak" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 22, 2001 10:49 AM Subject: [PHP] php-counter > hi! > > do you know an easy-to-use-php-counter, which uses mysql to store the data? > > gert > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php-counter
At 05:49 PM 8/22/01 +0200, you wrote: >hi! > >do you know an easy-to-use-php-counter, which uses mysql to store the data? > >gert Not off hand, but I could probably program one within the day. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] php-counter
hi! do you know an easy-to-use-php-counter, which uses mysql to store the data? gert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] counter using PHP or Javascript?
http://www.devshed.com/ClipScripts/results/l_2/c_6/ -Original Message- From: Zhu George-CZZ010 [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 11, 2001 9:42 AM To: [EMAIL PROTECTED] Subject: [PHP] counter using PHP or Javascript? Hi, Is there a way to create a counter to count the number of accesses for a apecific page using PHP or Javascript? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] counter using PHP or Javascript?
of course ;) try this method: link to the counter with an IMG from your page have counter.php increment a log file and output an image showing the current number of hits that "pagename" has gotten, so that the IMG SRC will be digits. (although, this is like reinventing the wheel, there are plenty of good & free counter programs out there) check this one out: http://www.muquit.com/muquit/software/Count/Count.html > -Original Message- > From: Zhu George-CZZ010 [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 11, 2001 12:42 PM > To: [EMAIL PROTECTED] > Subject: [PHP] counter using PHP or Javascript? > > > Hi, > >Is there a way to create a counter to count the number of accesses for > a apecific page using PHP or Javascript? > > Thanks. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] counter using PHP or Javascript?
Hi, Is there a way to create a counter to count the number of accesses for a apecific page using PHP or Javascript? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] counter reseting help!
How are you saving the current counter amount? For instance if it's in a database, add a date field. Check to see if the date is more than 24 hours old before displaying the current counter. If it is then update the database and make the counter number 0. If it's not older than 24 hours, just do your counter as normal. -- Plutarck Should be working on something... ...but forgot what it was. ""McShen"" <[EMAIL PROTECTED]> wrote in message 9b9mg0$26o$[EMAIL PROTECTED]">news:9b9mg0$26o$[EMAIL PROTECTED]... > hi > > I am writing a small counter for my site. But i am not sure how to reset the > counter every 24h. How should i do it? any suggestions would be much > appreaciated! > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] counter reseting help!
hi I am writing a small counter for my site. But i am not sure how to reset the counter every 24h. How should i do it? any suggestions would be much appreaciated! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Thanks, I still remember your reply on my test post be in touch! Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 24, 2001 4:26 PM To: 'PHPBeginner.com'; 'PHP (E-mail)' Subject: RE: [PHP] Counter Help Sounds good to me, I should, and will, always keep that in mind. Thanks for the tips. Also I want to say PHPBeginner.com is starting off very well, keep up the good work. I've been watching over it to see when the grand opening would be, and it's finally here. I hope it becomes a success someday. If I was good at PHP, I would contribute some articles, but I'm just a newbie for now. But maybe someday. Take it easy :) Sincerely, Navid Yar -Original Message- From: PHPBeginner.com [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 24, 2001 12:16 AM To: [EMAIL PROTECTED]; PHP (E-mail) Subject: RE: [PHP] Counter Help Yup, you need to have your key strings in quotes '', so it doesn't think it's a constant. ALWAYS use $array['key'] and not $array[key] except for the integrers Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 9:11 AM To: PHP (E-mail) Subject: [PHP] Counter Help Can someone help me with this script? It is an example from weberdev.com. I ran it and it gave me the following error... -- Warning: Use of undefined constant count - assumed 'count' in c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 25 The number 25 is the correct number for the counter, but how do I get rid of that error message that keeps coming up before the counter number (25)? I am testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL 3.23.33. Here is the script: -- Navid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Sounds good to me, I should, and will, always keep that in mind. Thanks for the tips. Also I want to say PHPBeginner.com is starting off very well, keep up the good work. I've been watching over it to see when the grand opening would be, and it's finally here. I hope it becomes a success someday. If I was good at PHP, I would contribute some articles, but I'm just a newbie for now. But maybe someday. Take it easy :) Sincerely, Navid Yar -Original Message- From: PHPBeginner.com [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 24, 2001 12:16 AM To: [EMAIL PROTECTED]; PHP (E-mail) Subject: RE: [PHP] Counter Help Yup, you need to have your key strings in quotes '', so it doesn't think it's a constant. ALWAYS use $array['key'] and not $array[key] except for the integrers Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 9:11 AM To: PHP (E-mail) Subject: [PHP] Counter Help Can someone help me with this script? It is an example from weberdev.com. I ran it and it gave me the following error... -- Warning: Use of undefined constant count - assumed 'count' in c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 25 The number 25 is the correct number for the counter, but how do I get rid of that error message that keeps coming up before the counter number (25)? I am testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL 3.23.33. Here is the script: -- Navid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Yeah, this is very silly thing using arrays without quotes, I once had this problem - learned it - and sticked to using quotes whenever is not an integrer. advising to everyone, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Simon Garner [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 1:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help From: "Chris Lee" <[EMAIL PROTECTED]> > change > > $row[count] > > to > > $row['count'] > > it thinks the work [count] is some kind of conastant, it doesnt know you > mean (string) 'count' > I have noticed a lot of people do not put quotes on their array indexes (e.g. VBulletin is a prime offender) - imho this is a really bad practice because your code becomes ambiguous. Example: "orange", "bar"=>"purple"); echo $test[foo]; ?> Now, I think that should print nothing (or an error), because there is no index matching "donkey" (the value of the constant "foo"). But for some reason PHP looks for an array index matching the string "foo" as well, encouraging this kind of sloppy programming. Regards Simon Garner -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Yup, you need to have your key strings in quotes '', so it doesn't think it's a constant. ALWAYS use $array['key'] and not $array[key] except for the integrers Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 9:11 AM To: PHP (E-mail) Subject: [PHP] Counter Help Can someone help me with this script? It is an example from weberdev.com. I ran it and it gave me the following error... -- Warning: Use of undefined constant count - assumed 'count' in c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 25 The number 25 is the correct number for the counter, but how do I get rid of that error message that keeps coming up before the counter number (25)? I am testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL 3.23.33. Here is the script: -- Navid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Thank you very much :) -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 4:55 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Fixed. Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 10:39 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Actually, I couldn't find the article number for that tutorial. I did, however, place a comment directly into that specific web page with the fix. Here is a direct link to the tutorial (I left the frames out): http://www.weberdev.com/ViewArticle.php3?ArticleID=30. Thanks. Navid -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 12:50 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help WeberDev will fix it ASAP if you tell it the number of the example :) Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 6:25 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Chris, It worked! Thanks so much! Weberdev needs to fix it too. Navid -Original Message- From: Chris Lee [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Fixed. Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 10:39 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Actually, I couldn't find the article number for that tutorial. I did, however, place a comment directly into that specific web page with the fix. Here is a direct link to the tutorial (I left the frames out): http://www.weberdev.com/ViewArticle.php3?ArticleID=30. Thanks. Navid -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 12:50 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help WeberDev will fix it ASAP if you tell it the number of the example :) Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 6:25 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Chris, It worked! Thanks so much! Weberdev needs to fix it too. Navid -Original Message- From: Chris Lee [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Actually, I couldn't find the article number for that tutorial. I did, however, place a comment directly into that specific web page with the fix. Here is a direct link to the tutorial (I left the frames out): http://www.weberdev.com/ViewArticle.php3?ArticleID=30. Thanks. Navid -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 12:50 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help WeberDev will fix it ASAP if you tell it the number of the example :) Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 6:25 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Chris, It worked! Thanks so much! Weberdev needs to fix it too. Navid -Original Message- From: Chris Lee [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
WeberDev will fix it ASAP if you tell it the number of the example :) Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 6:25 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Counter Help Chris, It worked! Thanks so much! Weberdev needs to fix it too. Navid -Original Message- From: Chris Lee [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Thanks for the great suggestion Simon, I'll definatley keep that in mind. I'm new to PHP, and the counter thing was "copied" off of Weberdev.com. They forgot to add the single quotes around counter. At least this experience helped me learn something new. Again, I thank you for your help and for Chris' help. Navid -Original Message- From: Simon Garner [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 10:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help From: "Chris Lee" <[EMAIL PROTECTED]> > change > > $row[count] > > to > > $row['count'] > > it thinks the work [count] is some kind of conastant, it doesnt know you > mean (string) 'count' > I have noticed a lot of people do not put quotes on their array indexes (e.g. VBulletin is a prime offender) - imho this is a really bad practice because your code becomes ambiguous. Example: "orange", "bar"=>"purple"); echo $test[foo]; ?> Now, I think that should print nothing (or an error), because there is no index matching "donkey" (the value of the constant "foo"). But for some reason PHP looks for an array index matching the string "foo" as well, encouraging this kind of sloppy programming. Regards Simon Garner -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Counter Help
From: "Chris Lee" <[EMAIL PROTECTED]> > change > > $row[count] > > to > > $row['count'] > > it thinks the work [count] is some kind of conastant, it doesnt know you > mean (string) 'count' > I have noticed a lot of people do not put quotes on their array indexes (e.g. VBulletin is a prime offender) - imho this is a really bad practice because your code becomes ambiguous. Example: "orange", "bar"=>"purple"); echo $test[foo]; ?> Now, I think that should print nothing (or an error), because there is no index matching "donkey" (the value of the constant "foo"). But for some reason PHP looks for an array index matching the string "foo" as well, encouraging this kind of sloppy programming. Regards Simon Garner -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Counter Help
Chris, It worked! Thanks so much! Weberdev needs to fix it too. Navid -Original Message- From: Chris Lee [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 22, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Counter Help change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Counter Help
change $row[count] to $row['count'] it thinks the work [count] is some kind of conastant, it doesnt know you mean (string) 'count' -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Navid Yar"" <[EMAIL PROTECTED]> wrote in message 000101c09d2d$135683e0$[EMAIL PROTECTED]">news:000101c09d2d$135683e0$[EMAIL PROTECTED]... > Can someone help me with this script? It is an example from weberdev.com. I > ran it and it gave me the following error... > > -- Warning: Use of undefined constant count - assumed 'count' in > c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 > 25 > > The number 25 is the correct number for the counter, but how do I get rid of > that error message that keeps coming up before the counter number (25)? I am > testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL > 3.23.33. Here is the script: > > > > > > > > > > > $hostname = 'localhost'; > $username = 'username'; > $password = 'password'; > $dbName = 'database'; > MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to > database"); > @mysql_select_db("$dbName") or die("Unable to select database"); > > $name = "$SCRIPT_NAME"; > > $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die > ("Bad query: ".mysql_error()); > $row = mysql_fetch_array($result); > > if($row){ > MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or > die ("Bad query: ".mysql_error()); > $count = $row[count]; > }else{ > MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad > query: ".mysql_error()); > $count = '1'; > } > echo $count; > ?> > > > > > -- Navid > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Counter Help
Can someone help me with this script? It is an example from weberdev.com. I ran it and it gave me the following error... -- Warning: Use of undefined constant count - assumed 'count' in c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 25 The number 25 is the correct number for the counter, but how do I get rid of that error message that keeps coming up before the counter number (25)? I am testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL 3.23.33. Here is the script: -- Navid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]