Re: Problem with app, condition not working.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 )

Does it get into the part where it should insert the data?

a simple

echo __LINE__ . '<br/>';

will tell you.


It could just be you have a bad insert query - you are not escaping any data at all.

Print out the query:

$insert_qry = "INSERT INTO track(page,ip,time,request_method,gateway_interface,server_protocol,request_time,query_string,accept_charset,
       accept_encoding,accept_language,http_connection,user_agent)
           VALUES ('$page',
                '$ip',
                '$time',
                '$request_method',
                '$gateway_interface',
                '$server_protocol',
                '$request_time',
                '$query_string',
                '$accept_charset',
                '$accept_encoding',
                '$accept_language',
                '$http_connection',
                '$user_agent')";

echo $insert_qry . '<br/>';

       $insertQuery = $sql->query($insert_qry);

and run it manually in mysql and see what happens.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux