eddorey2k3 Posted May 19, 2006 Share Posted May 19, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/10040-insert-command-super-easy-fix/ Share on other sites More sharing options...
.josh Posted May 19, 2006 Share Posted May 19, 2006 try this alternate method:[code]$adduserinfo = "INSERT INTO userlogging (ID, date, time, IP, browser, referer) VALUES ('', '$date', '$time', '$ip', '$useragent', '$referer')";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10040-insert-command-super-easy-fix/#findComment-37309 Share on other sites More sharing options...
eddorey2k3 Posted May 20, 2006 Author Share Posted May 20, 2006 Works like a charm. Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/10040-insert-command-super-easy-fix/#findComment-37406 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.