...

View Full Version : Wont update the DB..help



Disabled1
11-17-2006, 01:37 AM
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

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
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
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
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

SeeIT Solutions
11-17-2006, 03:34 AM
You are using the variable 'date' without the $ in front on 2 lines...



$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?

Disabled1
11-17-2006, 04:00 AM
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

Disabled1
11-17-2006, 05:23 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum