l_l asks
17 years ago
if you can grab referrer info using PHP
latest #49
Chris
17 years ago
$_SERVER['HTTP_REFERER']
l_l
17 years ago
Maybe you can help me out with some SQLing. I'm trying to set up something similar to the hits table, but instead store referrer info.
l_l
17 years ago
I think I can handle the PHP, but I still get lost with the SQL side.
立即下載
Chris
17 years ago
What part?
l_l
17 years ago
Creating the table to store the strings of referrers.
Chris
17 years ago
It's pretty easy with phpMyAdmin. You just need an id column, another numeric column for the redirect ID, then a varchar for the string.
Chris
17 years ago
(or text if you want to store things longer than 255 characters)
l_l
17 years ago
Would I put this in the r_redirects table?
Chris
17 years ago
No. It'd be a new table.
l_l is
17 years ago
there any reason why it couldn't be in the r_redirects?
Chris
17 years ago
Are you trying to log all of the referrals? You can do that if you want to serialize an array or something.
l_l
17 years ago
Perhaps not all of the referrals? Like, 10 or so. And...What does the rest mean...
Chris
17 years ago
Serializing an array turns it into a string, which you can then store in a database. Pretty handy. us.php.net/serialize
l_l
17 years ago
Ok, now I'm getting a MySql error. I think I'm doing it wrong. pastie.org/231461
Chris
17 years ago
What error, and with which query?
l_l
17 years ago
Chris
17 years ago
Have it print the entire query... I want to see what the error is.
Chris
17 years ago
(since that error report doesn't say a whole lot)
l_l
17 years ago
Uh...How do I do that?
l_l
17 years ago
Okay, I think I did it. but nothing shows up on the page. Its error number 1604, if that helps at all
Chris
17 years ago
In class.SQL.php, add $query somewhere in line 33 or 34.
l_l
17 years ago
blockquote>".$query."</blockquote> I put this in the query function, but nothing shows up.
Chris
17 years ago
Can you pastie me the file?
l_l
17 years ago
I did up above
l_l
17 years ago
Or do you want the misc.Sql thing
Chris
17 years ago
Pastie me the contents of class.SQL.php (with the $query addition)
l_l
17 years ago
Pastie no workie. xn--12-c6t.ws/includes/c...
l_l
17 years ago
Err, that should be class.SQL.txt, but whatever.
Chris
17 years ago
Whoops, try this: rafb.net/p/OI00N976.html
l_l
17 years ago
It's done.
Chris
17 years ago
Looks like 'referrers' isn't being set (and you should definitely have it in quotes)
l_l
17 years ago
Here's where I set it rafb.net/p/MWuf3G34.html. And what should I have in quotes?
Chris
17 years ago
Can I see the refer() function?
l_l
17 years ago
It should be in the pastie above
l_l
17 years ago
I think I might have renamed it a few times, but I don't think thats the problem
Chris
17 years ago
No, that's just calling the function. I want to see the function itself.
l_l
17 years ago
Right, thats in the pastie above. pastie.org/231461 <- This one.
l_l
17 years ago
Okay, No more SQL error, but it doesn't look like its storing any info...Hopefully I'll get this tomorrow.
l_l
17 years ago
I modified the code by adding ' around the referrer, and I got rid of the serialize for now. pastie.org/232403
l_l
17 years ago
Hmm. It looks like it worked once. img57.imageshack.us/img5...
l_l
17 years ago
Gahah! It works! Now to figure out the serialize thingie.
Chris
17 years ago
Only serialize if you're putting an array in there.
l_l
17 years ago
What about two strings?
Chris
17 years ago
You can probably just separate them with a string... serialization is more-so intended for nested arrays.
l_l
17 years ago
Here's where I got so far. I'm not sure if it works. pastie.org/232461
l_l
17 years ago
Nope, it definitely doesn't
Chris
17 years ago
What error does it produce?
l_l
17 years ago
Whoops, thats my fault. Was returning refer rather than referrers.
l_l
17 years ago
Now it is displaying a very wierd URL. I'm guessing thats cause of serialize? ½.WS/a?p
back to top