954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

MySQL/PHP Insert - Newbie Problem

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();

?>
rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 
$logger = "INSERT into doorbell (page, logdate, ip, agent) VALUES ('$ref', '$date', '$IP', '$agent')";
diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

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

Cheers mate!

rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 

Ok, great, are we solved?

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

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: