Re: Problem with app, condition not working.
| From: | PHP Mailer | Date: | Mon, 27 Mar 2006 02:50:01 +0000 |
| Subject: | Re: Problem with app, condition not working. | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232588@lists.php.net to get a copy of this message | ||
Chris skrev:
PHP Mailer wrote:Sorry about that, happens when writing it too fast and changing it too often. Fixed the problem now, did a match in the query instead. Thank you for the excellent help! JimmieChris skrev:Then this isn't a copy / paste of your script: #--> If in array if(!in_array($currentHost, $currentRules)) Comment says one, the code says another. Hello Chris,PHP Mailer wrote:Strangest thing is: if i add the excluded IP to the field in the DB it will insert the visitor info to the db, however if i remove the excluded ip from the filter, it wontChris skrev: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); }PHP Mailer wrote:Hello Chris, Returned output from the array is: Array ( [0] => 127.0.0.1 [host] => 127.0.0.1 )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?