|
Re: page "hit" counter [message #181990 is a reply to message #181988] |
Fri, 28 June 2013 23:00 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 6/28/2013 6:46 PM, 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";
>
> ?>
>
Look up the mysql_query() function in the doc.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: page "hit" counter [message #181991 is a reply to message #181988] |
Fri, 28 June 2013 23:16 |
David Robley
Messages: 23 Registered: March 2013
Karma: 0
|
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.
|
|
|
|
Re: page "hit" counter [message #181994 is a reply to message #181991] |
Fri, 28 June 2013 23:36 |
Scott Johnson
Messages: 196 Registered: January 2012
Karma: 0
|
Senior Member |
|
|
On 6/28/2013 4:16 PM, David Robley wrote:
> 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.
>
David
As i had to learn, Richard will not take notes or read manuals. He has
been warned numerous times to switch to mysqli and in particular how to
use the mysql_query function previously.
Just so you do not get frustrated.
Scotty
|
|
|
Re: page "hit" counter [message #181996 is a reply to message #181994] |
Fri, 28 June 2013 23:51 |
David Robley
Messages: 23 Registered: March 2013
Karma: 0
|
Junior Member |
|
|
Scott Johnson wrote:
> On 6/28/2013 4:16 PM, David Robley wrote:
>> 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.
>>
>
> David
>
> As i had to learn, Richard will not take notes or read manuals. He has
> been warned numerous times to switch to mysqli and in particular how to
> use the mysql_query function previously.
>
> Just so you do not get frustrated.
>
> Scotty
Thanks - I've seen previous dialogues with OP. Or perhaps that should be
monologues :-)
--
Cheers
David Robley
REALITY.SYS corrupted: Reboot universe? (Y/N/A)
|
|
|
Re: page "hit" counter [message #181997 is a reply to message #181993] |
Sat, 29 June 2013 00:31 |
Beauregard T. Shagnas
Messages: 154 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
richard the sto0pid wrote:
> Heh.
> Found a script on youtube that does the job I want.
Lucky you, because you've never ever written a script of your own in your
life.
--
-bts
-This space for rent, but the price is high
|
|
|