Jump to content


Photo

Hit Counter? Hits Updation


  • Please log in to reply
2 replies to this topic

#1 V-Man

V-Man
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationVermont

Posted 28 April 2006 - 07:24 PM

God, it's been forever since I posted last! And of course, I'm still asking for help. Sigh.. :)


include("bWd/includes/db.php");

$ref = $_GET['ref'];

$sql = "SELECT * FROM misc WHERE ref = '$ref'";

db_connect();

$result = mysql_query($sql)
         or die('Query failed. ' . mysql_error());

if (mysql_num_rows($result) == 1) {

    while ($row = mysql_fetch_array($result))
    {

        $insert = "UPDATE misc SET hits = ".$row['2']++."WHERE ref = '$ref'";
        mysql_query($insert) or mail('roughnroudy@gmail.com', 'Minvera Index DB Error', (mysql_error()));
        
    }
}

Anyway, heres the error:
Parse error: parse error, unexpected '\"' in /hsphere/local/home/minvera/minvera-fx.com/index.php on line 19

Im not missing any basic things like semi colons etc, at least as far as I can tell. This is my first attempt at a hit counter, so I thought I would come and ask the pro's when I got stuck. So here I am! :)

Basically, when I get a hit from a website that I have done (from the template desigh by link at the bottom of pages) I want to be able to tell who from and how many.

CREATE TABLE `misc` (
  `id` int(255) NOT NULL auto_increment,
  `ref` varchar(255) NOT NULL default '',
  `hits` varchar(255) NOT NULL default '',
  `info` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2;

rtfm :)

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 28 April 2006 - 07:30 PM

That's kind of a poor way to go about it. All you have to do is check to see if the reference is in the database already and if it is, just run an update:
UPDATE misc SET hits = hits + 1 WHERE ref = 'whatever'; <-- literally like that except for changing the "whatever" variable

If it's not already in the table, you'll want to do insert a new record.

Info: PHP Manual


#3 V-Man

V-Man
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationVermont

Posted 28 April 2006 - 07:41 PM

[!--quoteo(post=369673:date=Apr 28 2006, 03:30 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Apr 28 2006, 03:30 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
That's kind of a poor way to go about it. All you have to do is check to see if the reference is in the database already and if it is, just run an update:
UPDATE misc SET hits = hits + 1 WHERE ref = 'whatever'; <-- literally like that except for changing the "whatever" variable

If it's not already in the table, you'll want to do insert a new record.
[/quote]


Thanks. I tried that and got nothing but errors. THank thougs. Ill try just what you have again. See how that goes. Thanks Ober.

Solved
rtfm :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users