Jump to content

insert command, super easy fix.


eddorey2k3

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]
Link to comment
https://forums.phpfreaks.com/topic/10040-insert-command-super-easy-fix/
Share on other sites

Archived

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

×
×
  • Create New...

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.