Jump to content


Photo

insert command, super easy fix.


  • Please log in to reply
2 replies to this topic

#1 eddorey2k3

eddorey2k3
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 May 2006 - 10:16 PM

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)

$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");


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 May 2006 - 10:20 PM

try this alternate method:

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


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 eddorey2k3

eddorey2k3
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 May 2006 - 10:41 AM

Works like a charm. Thanks a lot!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users