PHP Mailer wrote:
Chris skrev:
PHP Mailer wrote:
Hey guys got a problem with an app i'm working on.
App: An app to track visitors and hosts visiting certain pages in a
website.
Situation: the app is to populate a table (db) with IP numbers which
are to be concidered as filtered/excluded in the below snippet of
code from being tracked.
Problem: the below code is used to insert the actual data for the
tracker from the visitor on the page its requested.
However, before the actual information is submitted, there has to be
a condition to see if the current visitor's IP is listed in the
excluded list. My current code returns false to all, and will not
input the data whether the IP is in the list or not in the table.
Culprit: Seems to be the in_array causing it or an eye-flaw from my
side but cannot find it.
//======================================================
#--> Include db config
require_once("../includes/db.class.phtml");
#--> Connect to db
$sql = new conSQL();
//======================================================
#--> Fetch current rules
$currentRulesQuery = $sql->query("SELECT host FROM filter");
if(!$currentRulesQuery){ print mysql_error(); }
#--> Result to array
#.
$currentHost = $_SERVER['REMOTE_ADDR'];
/* Obs: this loop runs all the rules *** do not edit */
while($currentRules = $sql->fetchArray($currentRulesQuery, MYSQL_ASSOC))
{
If you print our $currentRules:
var_dump($currentRules);
is it an array? What's in it?
Hello Chris,
Returned output from the array is:
Array ( [0] => 127.0.0.1 [host] => 127.0.0.1 )
If you think it's the in_array - check it:
if (in_array($currentHost, $currentRules)) {
echo "Host: $currentHost is in rules<br/>";
var_dump($currentRules);
}
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php