Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9943

Re: page "hit" counter

From David Robley <me@home.invalid>
Newsgroups comp.lang.php
Subject Re: page "hit" counter
Followup-To comp.lang.php
Date 2013-06-29 08:46 +0930
Organization albasani.net
Message-ID <kql5ev$nea$1@news.albasani.net> (permalink)
References <mdgl5xtqjxxk.10i5pahhaubg$.dlg@40tude.net>

Followups directed to: comp.lang.php

Show all headers | View raw


richard wrote:

> I am attempting to create a simple hit counter so I know how many times
> the page was actually viewed.
> The table is a simple 3 column deal.
> 1) id (key)
> 2) name
> 3) hits
> 
> 
> the code I have tried below returns the following error:
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource
> 
> What do I need to do to make this work right?
> 
> 
> <?php
> $con = mysql_connect('localhost','user','pass');
> if (!$con){die("can not connect: " . mysql_error());}
> mysql_select_db('richbull_top100',$con);
> 
> mysql_query($con,"UPDATE counter1 SET hits=hits++
> WHERE name='pickhit' ");
> 
> mysql_close($con);
> 
> echo "done";
> 
> ?>

Read the documentation for mysql_query again especially the arguments.

Note that the mysql_* functions are deprecated and you should consider using 
mysqli_* - see the warning at the top of the documentation page.
-- 
Cheers
David Robley

Useless Invention: Waterproof teabags.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

page "hit" counter richard <noreply@example.com> - 2013-06-28 18:46 -0400
  Re: page "hit" counter Jerry Stuckle <jstucklex@attglobal.net> - 2013-06-28 19:00 -0400
  Re: page "hit" counter David Robley <me@home.invalid> - 2013-06-29 08:46 +0930
    Re: page "hit" counter Scott Johnson <noonehome@chalupasworld.com> - 2013-06-28 16:36 -0700
      Re: page "hit" counter David Robley <me@home.invalid> - 2013-06-29 09:21 +0930
  Re: page "hit" counter richard <noreply@example.com> - 2013-06-28 19:31 -0400
    Re: page "hit" counter "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2013-06-29 00:31 +0000

csiph-web