Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wont update the DB..help

    Hello All,

    I have a problem with a script I have been working on for a few days and Im out of Ideas and eyes .

    The php script is supposed to send a visitor to 'pageB.php' if they have visited 'pageA.php' 5 times orr more. The attached wont add the info to the database.

    Need someone to test and tell me where its wrong ok?

    here is tables
    Code:
    CREATE TABLE `links` (
    `id` int(11) NOT NULL auto_increment,
    `ip` varchar(30) NOT NULL default '',
    `date` varchar(255) NOT NULL default '',
    `hits` int(5) NOT NULL default '1',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM;
    config.php
    PHP Code:
    <?php
    mysql_connect
    ("dbhost/ip","dbusername","dbpassword"); //database details
    mysql_select_db(database) or die(mysql_error()); //database connection

    $date date("d/m/Y"); //current date
    $ip $_SERVER['REMOTE_ADDR']; //ip address
    ?>
    addhits.php
    PHP Code:
    <?php
    require_once("config.php"); //file path to config, replace if you named it differently or placed it in a folder

    if($_GET[ip]) {
    $uip $_GET[ip]

    $selectip mysql_query("SELECT * FROM `links` WHERE `ip` = '$uip' AND `date` = 'date'") or die(mysql_error());
    $num mysql_num_rows($selectip) or die(mysql_error());

    if(
    $num <= '0') {
    mysql_query("INSERT INTO `links` (`ip`, `date`) VALUES ('$uip', '$date')") or die(mysql_error());
    }
    else
    {
    mysql_query("UPDATE `links` SET hits=(hits+1) WHERE `ip` = '$uip' AND `date` = 'date'") or die(mysql_error());
    }
    }
    ?>
    include.php
    PHP Code:
    <?php
    require_once("config.php"); //file path to config, replace if you named it differently or placed it in a folder

    $iphits mysql_query("SELECT * FROM `links` WHERE `ip` = '$ip' AND `date` = '$date'") or die(mysql_error());
    $iphits mysql_fetch_array($iphits) or die(mysql_error());

    if(
    $iphits[hits] >= '5') {
    echo(
    "You have the correct numbers of hits, you can view content");
    }
    else
    {
    echo(
    "incorrect number of hits");
    }
    }
    ?>
    help

    Valorie
    Last edited by Disabled1; 11-17-2006 at 04:55 AM. Reason: WRAPPED PHP CODE

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You are using the variable 'date' without the $ in front on 2 lines...

    PHP Code:
    $selectip mysql_query("SELECT * FROM `links` WHERE `ip` = '$uip' AND `date` = 'date'") or die(mysql_error());

    else
    {
    mysql_query("UPDATE `links` SET hits=(hits+1) WHERE `ip` = '$uip' AND `date` = 'date'") or die(mysql_error());

    Could that be the reason?

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks For taking the time to look and respond

    I will have to check in the morning as I have to reinstall MySQL. Will update in the morning.

    Thanks Again
    Valorie

  • #4
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No Go

    Made the changes above and it did not help. Someone is most likely going to have to install this and try it....I'm totally lost now Any help is appreciated.

    Valorie


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •