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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.