Jump to content


Clicks Counter Help


14 replies to this topic

#1 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 04 January 2006 - 06:41 PM

http://www.webclass.ru/eng/Tutorials/MySQL...ks_counter.html

The link listed was:
yoursite.com/urtoclickcounter/click.php?id=x (x= ur id in your database)

Let me get this straight. yoursite.com/urtoclickcounter/click.php? is the direct URL to the click.php, and the id=x (x being the URL to the actual link) is the link?

#2 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 04 January 2006 - 06:46 PM

all the id's are stored in a database, every id has its own column with the site url, so if your entering click.php?id=x it grabs the id and the database returns him the url

#3 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 04 January 2006 - 11:13 PM

Gah, I'm still confused. And I'm aware that's probably the simplest you can explain it to me.

#4 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 05 January 2006 - 08:05 AM

ok, the url looks something like this clicks.php?id=3. PHP grabs the id(3) and sends it a database table, which looks something like this
ID | URL | CLICKS
1 | site1.com | 5000
2 | tutorials.com | 125123
3 | anothertutsite.com | 100

id 3 is the key to anothertutsite.com and 100 clicks. it adds one click so now there are 101 outgoing clicks, then it redirects you to anothertutsite.

Hope you understand it now :)

#5 dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 05 January 2006 - 11:02 AM

Okay,

?id=x

The id is there because of how the script is set up. The "X" means that that is the number of the site.

ex: ?id=1

That is link one every time you click ?id=1 it will increase the amount of clicks for that link.

?id=2

is your second link and every time you click it, it will increase the amount of click for that link.


The "1, 2, 3, 4 etc" after the ?id= just defines which part of the database to increase the amount of clicks.

Hope that helped you a bit more.

dEcade

#6 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 05 January 2006 - 12:32 PM

Wow, that clears things up... a lot. I'm assuming making the tables won't require much quering (hopefully).

How would I echo that info up into text format?

#7 dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 05 January 2006 - 01:31 PM

Like to show how many click that one site has? Please explain more.

dEcade

#8 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 08 January 2006 - 05:58 PM

2 big questions. One, how would I echo the information (how many times the link has been clicked) on a site? Two, the link would be yoursite.com/urtoclickcounter/click.php?id=x. This link is to the counter, and then will it automatically forward to the actual link (the page it is counting hits for)?

Additionally, what does this error mean: "Fatal error: Call to undefined function: is_numerical() in /home/g9core/public_html/count.php on line 16"

Edited by G.9, 08 January 2006 - 07:05 PM.


#9 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 08 January 2006 - 08:46 PM

Well, i'll answer your last question.
It means you had a fatal error, you called a function that doesn't exist. The file it was called from is "/home/g9core/public_html/count.php", on line 16.
The function you want to use is is_numeric().

Edited by rc69, 08 January 2006 - 08:46 PM.


#10 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 08 January 2006 - 09:05 PM

Thanks, that error has passed and gone... but I have encountered another.

Table 'g9core_click.affiliates' doesn't exist

What does that mean? To see the query I submitted and the table structure of the database, click here.

#11 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 09 January 2006 - 09:48 AM

Anyone willing to aid a helpless soul? :ph34r:

#12 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 09 January 2006 - 09:22 PM

Don't double post, give people some time to respond.

Quote

CREATE TABLE `clickscount`
I didn't see anything in that tutorial about creating the table "affiliates." You were told to create "clickscount" and then everything else deals with "affiliates", which is why you're getting that error.
Change the table name and try again.

#13 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 13 January 2006 - 02:16 AM

[UselessPost]
The tutorial maker should be stoned to death.
[/UselessPost]

#14 G.9

    Young Padawan

  • Members
  • Pip
  • 38 posts

Posted 13 January 2006 - 10:05 AM

This is what I have uploaded currently:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
$result = mysql_query("SELECT id,url,count FROM counter_table WHERE id='$id'");
$row = mysql_fetch_array($result);

	$id=$row['id'];
	$count=$row['count'];
	$count = $count;
	$update = "UPDATE counter_table SET count='$count' WHERE id='$id' ";
	$updatesql = mysql_query($update);

$sql = mysql_query("SELECT id,url FROM counter_table WHERE id='$id'");
$row = mysql_fetch_array($sql);
$id = $row['id'];
$url = $row['url'];
header("Location: $url");
mysql_close();
?>
</body>
</html>
I also found this, I believe this is just a display file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?
mysql_connect("localhost","g9core_click","arvyandson") or die(mysql_error());

mysql_select_db("g9core_click");

echo "<h3>Affiliates</h3>";

$result = mysql_query("SELECT * FROM affiliates ORDER BY id") or die(mysql_error());

echo "<table><tr>";

while($row = mysql_fetch_array($result)){
echo "<td>";
echo "<a href=\"count.php?id=" . $row['id'] . "\" target=\"_blank\">" . $row['affname'] . "</a><br>";
echo "Clicks: " . $row['clicks'];
echo "</td>";
}
echo "</tr></table>";
?>
</body>
</html>

Which do I use, and what's wrong with each?

Edited by rc69, 13 January 2006 - 04:18 PM.


#15 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 13 January 2006 - 04:20 PM

I put edited your post and put the code in [ code ] tags for legibility, please remember to use them in the future.

And i would probably use the top code since it uses the correct table, but the only way to really know if anything is wrong is to upload them to your server and try them out.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users