I'm making a simple IP logger. I've tested the script, but the database doesn't seem to filling up. It could be a problem with the database format etc, details below. Otherwise, I must have made an newbie oversight in the PHP. Some fresh eyes would be greatly appreciated!

id: INT(10), unsigned, NN, primary key, auto_inc
page: VARCHAR(255), NN
logdate: VARCHAR(100), NN
ip: VARCHAR(100), NN
agent: MEDIUMTEXT, NN

<?php

include 'ip_finder.php'; // IP finder script, returns the variable $IP
include 'config.php'; // Database details
$tbl_name="table";

$ref = $_SERVER['REQUEST_URI'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$date = date("F j, Y, g:i a");

// echo $ref." ".$date." ".$IP." ".$agent;

$logger = "INSERT into doorbell ('page', 'logdate', 'ip', 'agent') VALUES ('$ref', '$date', '$IP', '$agent')";

if (!$logger){ 
	die('Could not connect: ' . mysql_error());
	} else {
		echo "1 record added";
	}

mysql_close();

?>

Recommended Answers

All 3 Replies

Member Avatar for diafol
$logger = "INSERT into doorbell (page, logdate, ip, agent) VALUES ('$ref', '$date', '$IP', '$agent')";

hmmm. that seems to have done it... Although I swear I already tried without quotes...
some sort of devil magic going on..

Cheers mate!

Member Avatar for diafol

Ok, great, are we solved?

If so, click the link below 'Thread Solved' or whatever it says. Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.