FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » page "hit" counter
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: page "hit" counter [message #181991 is a reply to message #181988] Fri, 28 June 2013 23:16 Go to previous messageGo to previous message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma:
Junior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: $referrer = $_SERVER['HTTP_REFERER'] echo
Next Topic: DIY finger tip typin - pace and code, (PHP open source)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 09:31:46 GMT 2024

Total time taken to generate the page: 0.03380 seconds