Jump to content

Archived

This topic is now archived and is closed to further replies.

eddorey2k3

insert command, super easy fix.

Recommended Posts

Hello!
I'm sure this is a super simple fix, but for some reason I'm not seeing it. Any help would be good.

The PHP is designed to capture certain information about the site visitor, and then store them in a database. Simple, really. The information is being captured, but for some reason, it's inputting the variable names into the database, instead of the values.

It connects to the database correctly, and picks up the right table. The problem is that it submits the variable names, instead of the value.....even though I've already said that.

The original code was obtained from the PHP website (I believe), but that used static values instead of dynamic variables.

I'm assuming it's something to do with the variable names being in brackets?

Code below. (The relevant section)

[code]$date = date("D dS F, Y");
$time = date("g:i:sa"); //find out how to get this back into GMT
$ip = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$useragent = $_SERVER['HTTP_USER_AGENT'];
/*Adds the data to the database*/

$db = "databasename";
$result = mysql_select_db($db) or die("Unable to select the database, but could connect to server");

$adduserinfo = 'INSERT INTO `userlogging` (`ID`, `date`, `time`, `IP`, `browser`, `referer`) VALUES (\'\', \'$date\', \'$time\', \'$ip\', \'$useragent\', \'$referer\')';
$adduserinforesult = mysql_query($adduserinfo) or die ("Error in query $adduserinfo");[/code]

Share this post


Link to post
Share on other sites
try this alternate method:

[code]
$adduserinfo = "INSERT INTO userlogging (ID, date, time, IP, browser, referer) VALUES ('', '$date', '$time', '$ip', '$useragent', '$referer')";
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.