Create a website counter with php

I am trying to create a website counter with php

Page 1 of 1

1 Replies - 1502 Views - Last Post: 26 October 2010 - 07:19 PM Rate Topic: -----

#1 Codin  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 45
  • Joined: 31-March 10

Create a website counter with php

Posted 26 October 2010 - 07:06 PM

I am trying to create a website counter which inserts the information into my database, and displays it on my website also. I am testing it first in localhost so that is why I using localhost as my website. Here is my code.

<?php
		 // Connects to your Database 
		 mysql_connect("http://localhost/counter.html", "root", "######password") or die(mysql_error()); 
		 mysql_select_db("db#####") or die(mysql_error()); 
		
		//Adds one to the counter 
		mysql_query("UPDATE counter SET counter = counter + 1");
		
		//Retreives the current count 
		$count = mysql_fetch_row(mysql_query("SELECT counter FROM counter"));
		
		//Displays the count on your site
		 print "$count[0]"; ?>

and this is the is the html with the php include() I am trying to use to get the counter to appear on the website.
 <head>
    <title>counter test</title>
      </head>
      
      <body>
      <?php include("http://localhost/counter.php"); ?> 
      
      </body>
      </html>
 
All help greatly appreciated. Codin :donatello:

Is This A Good Question/Topic? 0
  • +

Replies To: Create a website counter with php

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2896
  • View blog
  • Posts: 10,036
  • Joined: 08-August 08

Re: Create a website counter with php

Posted 26 October 2010 - 07:19 PM

Does it not work?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1