jackr1909 Posted August 6, 2011 Share Posted August 6, 2011 Hi i have this anylitics code: <?php $con = mysql_connect("localhost","root","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("INSERT INTO Persons (id, url, ip, referringurl, date, time) VALUES ('', '{$_GET['S']', '$_SERVER['REMOTE_ADDR']', '$SERVER['URL_REFER'], '', '')"); mysql_query("i don't know the syntax for hits"); mysql_close($con); ?> it isn't working. i can use an external config file if necessary but what i basically want to do is insert the referring url, users IP, time, date, and increase a value in the 'hits' table for every query. Time and date added in mysql Link to comment https://forums.phpfreaks.com/topic/244013-php-any-mysql-anylitics-code/ Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Your missing a } inside the query for $_GET, which is unprotected and this can be a security issue (see mysql_real_escape_string) date and time are reserved I believe, hence you need the TICKS `` You are also missing a single quote $con = mysql_connect("localhost","root","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("INSERT INTO Persons (`id`, `url`, `ip`, `referringurl`, `date`, `time`) VALUES ('', '{$_GET['S']}', '{$_SERVER['REMOTE_ADDR']}', '{$SERVER['URL_REFER']}', '', '')"); for the hits value, see mysql UPDATE Link to comment https://forums.phpfreaks.com/topic/244013-php-any-mysql-anylitics-code/#findComment-1253112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.