denoteone Posted April 6, 2009 Share Posted April 6, 2009 quire_once('visitors_connections.php');//the file with connection code and functions //get the required data $visitor_ip = $_SERVER['REMOTE_ADDR']; $whois_ip_server = 'whois.arin.net'; $ip_info = whois_ip($whois_ip_server, '-1', 'FALSE', $visitor_ip); $visitor_hour = date("h"); $visitor_minute = date("i"); $visitor_day = date("d"); $visitor_month = date("m"); $visitor_year = date("Y"); $visitor_ref = GetHostByName($_SERVER['HTTP_REFERER']); $visitor_page = curPageURL(); //write the required data to database mysql_select_db($database_visitors, $visitors); $sql = mysql_query(sprintf("SELECT `visitor_ip`,`visitor_day` FROM `visitors_list` WHERE `visitor_ip` = '%u' AND `visitor_day` = '%u';",(int)$visitor_ip,(int)$visitor_day)) or die('error!'); if(mysql_num_rows($sql)) { $sql_con = concat(pages,'$visitor_page') WHERE visitor_ip = '$visitor_ip' AND visitor_date = '$visitor_day'; $result = mysql_query($sql_con) or trigger_error(mysql_error(),E_USER_ERROR); }else{ $ip_info = mysql_real_escape_string($ip_info); $sql = "INSERT INTO visitor_list (visitor_ip, visitor_whois, visitor_min, visitor_hour, visitor_day, visitor_month, visitor_year, visitor_ref, visitor_page) VALUES ('$visitor_ip','$ip_info','$visitor_hour', '$visitor_minute', '$visitor_day', '$visitor_month','$visitor_year', '$visitor_ref', '$visitor_page')"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); } I think the issues is somewhere in the first if statement but i am not getting any errors but I am also not getting any info in my DB. anyone see what I am doing wrong? Link to comment https://forums.phpfreaks.com/topic/152809-php-and-mysqls-concat/ Share on other sites More sharing options...
premiso Posted April 6, 2009 Share Posted April 6, 2009 $sql_con = concat(pages,'$visitor_page') WHERE visitor_ip = '$visitor_ip' AND visitor_date = '$visitor_day'; That statement makes no sense. A. You do not have a SELECT FROM statement. B. You are not encapsulating the variable in quotes. $sql_con = "SELECT concat(`pages`,'$visitor_page') FROM `visitors_list` WHERE visitor_ip = '$visitor_ip' AND visitor_date = '$visitor_day'"; I did not bother looking through anything else cause it is poorly indented. Link to comment https://forums.phpfreaks.com/topic/152809-php-and-mysqls-concat/#findComment-802488 Share on other sites More sharing options...
sasa Posted April 6, 2009 Share Posted April 6, 2009 can we see your concat() function Link to comment https://forums.phpfreaks.com/topic/152809-php-and-mysqls-concat/#findComment-802493 Share on other sites More sharing options...
denoteone Posted April 6, 2009 Author Share Posted April 6, 2009 The concat is a built in mysql function that adds the visitor page variable to the field pages. I just took a stab at the sql statement I am sure that is were i am going wrong. Link to comment https://forums.phpfreaks.com/topic/152809-php-and-mysqls-concat/#findComment-802506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.