Jump to content

[SOLVED] Mysql and Arrays


Haggis

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/106914-solved-mysql-and-arrays/
Share on other sites

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

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

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.