Jump to content

Recommended Posts

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

$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.

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.