Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Here is the Script

    Code:
    <?
    <head><meta http-equiv="pragma" content="no-cache"></meta></head>
    $host= "localhost";
    $dbuser = "wplanet_dbuser";
    $dbpass = "********";
    $dbname = "wplanet_sql";
    mysql_connect($host, $dbuser, $dbpass);
    mysql_select_db($dbname);
    $url = $_GET['url'];
    $result = mysql_query("SELECT * FROM counter WHERE url='$url'");
    $row = mysql_fetch_array($result);
        $id=$row[id];
        $count=$row[count];
        $count = $count + 1;
        
        $update = "UPDATE counter SET count='$count' WHERE id='$id' ";
        $updatesql = mysql_query($update);
    
    mysql_close();
    echo "<script language=\"JavaScript\">
    document.location.href=\"". $url ."\"
    </script>";
    ?>
    The SQL staff is
    Code:
    CREATE TABLE `counter` (
      `id` int(11) NOT NULL auto_increment,
      `url` text NOT NULL,
      `count` bigint(20) NOT NULL default '0',
      KEY `id` (`id`)
    ) TYPE=MyISAM;
    The problem is that Script does redirect but dont count the hit
    Link type is http://www.mywebsite.com/linktophpco...www.blabla.com
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    I dunno.... seems to me like you're complicating the issue...

    I'm not a PHP expert by any means, but try this:

    PHP Code:
    <head><meta http-equiv="pragma" content="no-cache"></meta>
    <?
    $host
    "localhost";
    $dbuser "wplanet_dbuser";
    $dbpass "********";
    $dbname "wplanet_sql";
    mysql_connect($host$dbuser$dbpass);
    mysql_select_db($dbname);
    $url $_GET['url'];
    $update_query "UPDATE counter SET count = count + 1 WHERE url = '$url'";
    mysql_query($update_query);
    mysql_close();
    echo 
    "<script language=javascript>document.location.href='$url'</script>";
    ?>
    </head>

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Also, try this:

    KEY `pk_counter` (`id`)

    instead of

    KEY `id` (`id`)

    The reason is, you don't want to name your pk the same as the column. It could confuse the database if the two objects have the same name. Not likely, but possible. Even if not the database, it could confuse other developers who might be using it in the future.

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Also, are you sure that $_GET('url') is returning anything and that it is matching the url in your table?

    why not do some echos of the $_GET('url') and compare the results with the url in your table?

  6. #5
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    I wll give it a try, thx!
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com