Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Referring Website trouble
Old 06-13-2010, 08:11 PM Referring Website trouble
Skilled Talker

Posts: 83
Trades: 0
I am trying to capture the website's name that links to my website. When a person clicks that link, it should add it to my database. For some reason though, it isn't working. Any suggestions?

Code:
<?php
include('inc/connect.php');

$today = date("Y-m-d");
$ip = $_SERVER['REMOTE_ADDR'];
$referrer = getenv('HTTP_REFERER');
$referrerfinal = parse_url($url, PHP_URL_HOST);

echo $referrerfinal;
$check = mysql_query("SELECT * FROM uniquevisitors WHERE ip='$ip'");
$unique = mysql_num_rows($check);
if ($unique==0)
{
  $insert = mysql_query("INSERT INTO uniquevisitors VALUES ('',now(),'$ip','$referrerfinal')");
}
else
{
  exit();
}

?>
Database:

Code:
countid      int(11)       No                
date     datetime     No      0000-00-00 00:00:00       
ip     varchar(20)     No             
referrer     varchar(255)     No
Thanks
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-14-2010, 11:14 AM Re: Referring Website trouble
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Replace exit() with mysql_error() to see what's wrong with your query.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-14-2010, 11:16 AM Re: Referring Website trouble
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Lol, wrong.

if (!$insert)
print(mysql_error());
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-14-2010, 11:19 AM Re: Referring Website trouble
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Also it is very inefficient to store IP addresses as 20 bytes varchar since it can be stored as 4 bytes int and easily converted between int and string with ip2long() and long2ip() functions respectively.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-15-2010, 11:59 AM Re: Referring Website trouble
Skilled Talker

Posts: 83
Trades: 0
Tried adding the code to check for any errors, and it returns nothing. I've been told that http_referer doesn't store the value very well. not sure what to do to get it to work.
Smudly is offline
Reply With Quote
View Public Profile
 
Old 06-15-2010, 12:46 PM Re: Referring Website trouble
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
So the problem is that your query fails while being executed or is not executed at all due to condition that is never true? Or how exactly does it "not work"?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-15-2010, 01:15 PM Re: Referring Website trouble
Skilled Talker

Posts: 83
Trades: 0
It does not input the value (referrals) into the database. that is what is supposed to be working, but it isn't.
Smudly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Referring Website trouble
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49392 seconds with 12 queries