Haggis Posted May 23, 2008 Share Posted May 23, 2008 ok i have a table in my stats package that has Last 10 referrers now what i want to do is have an array in the config file so that i can block spam sites from the listing so say the block list includes www.google.com www.yahoo.com www.msn.com so how can i on insert get it to check if the domain is included in the array would i do it like this if $domain is in array { exit } else { insert statement } ? or is there a better way to do this Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/ Share on other sites More sharing options...
DarkWater Posted May 23, 2008 Share Posted May 23, 2008 if (in_array($block, $domain)) { Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-547973 Share on other sites More sharing options...
Haggis Posted May 23, 2008 Author Share Posted May 23, 2008 for testing purposes i have this if (in_array($blocked,$ref)) { echo "BLOCKED"; } else { echo "NOT BLOCKED"; } getting this error Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/public_html/browser.php on line 288 NOT BLOCKEDError: Query was empty this is my array $blocked[] = "www.haggistech.co.uk"; $blocked[] = "haggistech.co.uk"; any ideas Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548030 Share on other sites More sharing options...
micmania1 Posted May 23, 2008 Share Posted May 23, 2008 is $ref a mysql array? If so then you will have to change it to $ref['blocked'] Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548051 Share on other sites More sharing options...
Haggis Posted May 23, 2008 Author Share Posted May 23, 2008 nah its not at the top of the file i have $ref = getenv('HTTP_REFERER'); Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548065 Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 the problem is your in_array arguments are reversed. It's in_array(needle, haystack) Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548095 Share on other sites More sharing options...
Haggis Posted May 23, 2008 Author Share Posted May 23, 2008 ok this is working now if (in_array($ref,$blocked)) { echo "BLOCKED"; } else { echo "NOT BLOCKED"; } but say i block www.google.co.uk the referrer is http://www.google.co.uk/search?hl=en&q=haggistech&meta= how can i alter if (in_array($ref,$blocked)) { echo "BLOCKED"; } else { echo "NOT BLOCKED"; } to find out if www.google.co.uk is in the string Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548107 Share on other sites More sharing options...
sasa Posted May 23, 2008 Share Posted May 23, 2008 $ref = getenv('HTTP_REFERER'); $ref1 = parse_url($ref); $ref = $ref1['host']; Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548143 Share on other sites More sharing options...
Haggis Posted May 24, 2008 Author Share Posted May 24, 2008 thanks guys worked fine Quote Link to comment https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/#findComment-548826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.