php-general Digest 27 Mar 2006 01:34:15 -0000 Issue 4036

2006-03-26 Thread php-general-digest-help

php-general Digest 27 Mar 2006 01:34:15 - Issue 4036

Topics (messages 232574 through 232576):

Re: Oject passed via session error
232574 by: Chris

Re: PHP Links
232575 by: Kevin Waterson

Re: Creation and transfer of object thru session
232576 by: Chris

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---
You need to declare the class before you call session_start(). Otherwise 
it can't create the object properly.


Peter Lauri wrote:

Hi,

I do this:

?php
session_start();
require_once('classes/ns_cart.class.php');
if(!isset($_SESSION['ns_cart'])) $_SESSION['ns_cart'] = new NScart();
?

The output will be the following with print_r of the $_SESSION:


Array
(
[ns_cart] = nscart Object
(
[myProducts] = Array
(
[0] = ns_product Object
(
-


When I reloads the page I get the following:


Array
(
[ns_cart] = __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] = nscart
[myProducts] = Array
(
[0] = __PHP_Incomplete_Class Object
-

What is this? I am confused...

/Peter

  
---End Message---
---BeginMessage---
This one time, at band camp, Thomas Bonham [EMAIL PROTECTED] wrote:

 I'm trying to find out how make following happen
 
 Example:
 http://www.example.com/test.php?id=20

in test.php put this code

?php echo $_GET['id']; ?

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.
---End Message---
---BeginMessage---

Peter Lauri wrote:

Hi,

I am creating an object from a Web Service. Throughout a session I would
like to keep the object that was created in the beginning of the session.
The reason for this is that the creation of the object takes some time
because of the communication with the Web Service. As I see it, there are
two possibilities:

1. Save the object in the $_SESSION variable, because the objects are not
big
2. Serialize the object and save it to a database, and use $_SESSION to keep
reference to the database

What is to prefer? What are the benefits of using 1 against using 2? Is
there any 3rd option?


I'd probably go with #1 mainly because it's always available through 
$_SESSION - you don't have to hit the db to keep getting it.


--
Postgresql  php tutorials
http://www.designmagick.com/
---End Message---


Re: [PHP] Creation and transfer of object thru session

2006-03-26 Thread Chris

Peter Lauri wrote:

Hi,

I am creating an object from a Web Service. Throughout a session I would
like to keep the object that was created in the beginning of the session.
The reason for this is that the creation of the object takes some time
because of the communication with the Web Service. As I see it, there are
two possibilities:

1. Save the object in the $_SESSION variable, because the objects are not
big
2. Serialize the object and save it to a database, and use $_SESSION to keep
reference to the database

What is to prefer? What are the benefits of using 1 against using 2? Is
there any 3rd option?


I'd probably go with #1 mainly because it's always available through 
$_SESSION - you don't have to hit the db to keep getting it.


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

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



[PHP] Problem with app, condition not working.

2006-03-26 Thread PHP Mailer

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.


Any ideas?

Jimmie




//==
#-- 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 in array
   if(!in_array($currentHost, $currentRules))

   {   
   #---#

   #-- Fetch data
   $currentSettingsQuery = $sql-query(SELECT track_control FROM define);
   if(!$currentSettingsQuery){ print mysql_error(); }


   #-- Data to var
   $currentSettings = $sql-fetchArray($currentSettingsQuery);

   if($currentSettings['track_control']==1)
   {
  
  
   // Specify the tracking vars # Revision 1.0

   //==
   $page = $_SERVER['PHP_SELF']; // full path
   $ip = $_SERVER['REMOTE_ADDR']; // interface protocol
   $time = date(Y-m-d H:i:s); // current time and date
   $request_method = $_SERVER['REQUEST_METHOD']; // refer agent method
   $gateway_interface = $_SERVER['GATEWAY_INTERFACE']; // refer 
agent gateway
   $server_protocol = $_SERVER['SERVER_PROTOCOL']; // host server 
protocol
   $request_time = $_SERVER['REQUEST_TIME']; // time of request ( 
php 5.1.0 up )
   $query_string = $_SERVER['QUERY_STRING']; // query string if 
available
   $accept_charset = $_SERVER['HTTP_ACCEPT_CHARSET']; // refer 
agent charset
   $accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING']; // refer 
agent encoding
   $accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE']; // refer 
agent language
   $http_connection = $_SERVER['HTTP_CONNECTION']; // service 
connection

   $user_agent = $_SERVER['HTTP_USER_AGENT']; // refer agent
   #$remote_port = $_SERVER['REMOTE_PORT']; // refer agent port
   //==
  
  
   #-- Continue with the query

   $insertQuery = $sql-query(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'));
  
   }

   }
}
   #---#

   #-- Error check on query
   if(!($insertQuery)){ print mysql_error(); }
   else
   {

   #.
   $sql-close();
  
   }

   //==
?

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread Chris

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?


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

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread PHP Mailer

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 )

Yes, it's fetched from the fields in the belonging table (filter)

- Jimmie

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



Re: [PHP] opening .Z archive with gzopen

2006-03-26 Thread Chris

nicolas figaro wrote:

Hi

I'm using php 4.3.11 on linux RH9.

I'd like to open a .Z archive with gzopen.
I looked at the options of gzopen, but I'm not sure there is a way to 
specify the compression used by compress/uncompress.


Has anyone ever tried and done this yet ? (without a system(uncompress 
$file)


Since a compressed file isn't the same as a gzipp'ed file I'd guess this 
won't work.


This might:

http://pear.php.net/package/File_Archive

but it doesn't mention .Z files specifically.

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

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



Re: [PHP] opening .Z archive with gzopen

2006-03-26 Thread PHP Mailer

Chris skrev:

nicolas figaro wrote:

Hi

I'm using php 4.3.11 on linux RH9.

I'd like to open a .Z archive with gzopen.
I looked at the options of gzopen, but I'm not sure there is a way to 
specify the compression used by compress/uncompress.


Has anyone ever tried and done this yet ? (without a 
system(uncompress $file)


Since a compressed file isn't the same as a gzipp'ed file I'd guess 
this won't work.


This might:

http://pear.php.net/package/File_Archive

but it doesn't mention .Z files specifically.

Seems to me like it's the in_array causing this, I need a way to see if 
the current IP matches any in the Array


- Jimmie

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



[PHP] Err wrong reply addr

2006-03-26 Thread PHP Mailer

Sorry guys

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread Chris

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread PHP Mailer

Chris skrev:

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.


Hey Chris,

the query works fine if i remove the condition to check for the IP

- Jimmie


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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread Chris

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 rulesbr/;
  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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread PHP Mailer

Chris skrev:

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 rulesbr/;
  var_dump($currentRules);
}


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 wont


It's upsidedown!

- Jimmie

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread Chris

PHP Mailer wrote:

Chris skrev:


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 rulesbr/;
  var_dump($currentRules);
}


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 wont


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.

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

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



Re: [PHP] Problem with app, condition not working.

2006-03-26 Thread PHP Mailer

Chris skrev:

PHP Mailer wrote:

Chris skrev:


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 rulesbr/;
  var_dump($currentRules);
}


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 wont


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,

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!

Jimmie

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



[PHP] array_search function bugged? update

2006-03-26 Thread je killen

Hi all
Here is an update on my problem reported with the array_search function.
to those who directed me to the bug report page, thanks.
There are a number of reports specific to this function. Maybe event
someone else has written a fix.
here is my solution to my problem.

The following code* was developed and finalized by J.E.Killen 3/2006
* accept of course for array_search() itself.
function word_wise(array $input, int $what) //returns an array
  {$str = array();
   $stra = array();
   $str = str_split($input); //turns string into 
array
   $stra = $str; // saves a copy for final 
reconcilliation

   $tmp = '';// used to hold and transfer values
   $final = array(); // ***THE WHOLE POINT
   $reduced = array(); // reduction array
   $formula = array(); // interum array
   $output = array();  // test output.
   for($i = 0; $i  count($str); $i++)
{$formula[$i] = array_search($str[$i], 
$str);

 if($formula[$i]  $i) // use of $formula
 {$str[$i] = '';} // repeats eliminated from $str
}; // if $i is greater than formula[$i], formula[$i] is 
a repeat.
for($i = 0; $i  count($str); $i++)
   {if($str[$i] != '') // looks for empty 
strings in $str

  {
array_push($reduced, $str[$i]); // 
fills $reduced with
// non 
empty $str items
// to 
produce an array of
// all 
unique letters

   }
   };
   for($i = 0; $i  count($stra); $i++)
  {for($j = 0; $j  count($reduced); $j++)
  {
if($stra[$i] == $reduced[$j])//produces 
the final formula for
   {$final[$i] = $j; }   // 
reconstruction of the word.

  }
   }
   for($i = 0; $i  count($final); $i++)
  { $tmp = $final[$i];
$output[$i] = $reduced[$tmp]; //test run 
reconstructs word from $final and  $reduced.

   }
   switch($what) //options to chose what to return
  {case 1:
   return $reduced; //reduction to all unique 
letters

   break;
   case 2:
   return $stra;//original
   break;
   case 3:
   return $final;   // reconstruction formula
   break;
   case 4:
   return $output;  //test
   break;
}
 } // end word_wise()

Just want to return something to the php community
Jeff K

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



[PHP] array_search function bugged update errata

2006-03-26 Thread je killen

sorry all for the mistake in the code;
in this line 'array $input' should be string $input.
function word_wise(array $input, int $what) //returns an array
so it reads
function word_wise(string $input, int $what) //returns an array
this should be the only mistake. I added this stuff as an afterthought 
after

all the code was working perfectly in my test code.
best
JK

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



[PHP] mysql_fecth_array() and function call as parameter

2006-03-26 Thread Paul Goepfert
Hi all,

I have wriiten a function that determines whether tomorrows date is
the first of the month or not then returns a SQL string based on
whether its the first of the month or not.  According to my apache
error logs I get an error that says:

[Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: 
mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\validation.php on line 331

I understand that this is a warning but I believe that it has
something to do with the fact that no output is being displayed.  All
other mysql database outputs work fine.

This is the code that sets the query in the mysql_query parameter

$Month_query = mysql_query($this-determineMonth());

this is the code for determineMonth ()

function determineMonth()
{
$return = ;
$query1 = mysql_query(SELECT months FROM Month WHERE m_id =
month(curdate()));
$query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum =
day(curdate()));
$query3 = mysql_query(SELECT year FROM Year WHERE year = 
year(curdate()));

switch ($query1)
{
case January:
case March:
case May:
case July:
case August:
case October:
case December:
if($query2 == 31)
$return = SELECT m_id, months FROM 
Month WHERE m_id =
month(curdate())+1;
else
$return = SELECT m_id, months FROM 
Month WHERE m_id = month(curdate());
break;
case February:
if ($query2 == 28 || $query2 == 29)
$return = SELECT m_id, months FROM 
Month WHERE m_id =
month(curdate())+1;
else
$return = SELECT m_id, months FROM 
Month WHERE m_id = month(curdate());
break;
case April:
case June:
case September:
case November:
if ($query2 == 30)
$return = SELECT m_id, months FROM 
Month WHERE m_id =
month(curdate())+1;
else
$return = SELECT m_id, months FROM 
Month WHERE m_id = month(curdate());
break;
}
return $return;
}

I hope I included everything.  If not let me know and I'll post it

Paul

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



Re: [PHP] mysql_fecth_array() and function call as parameter

2006-03-26 Thread Chris

Paul Goepfert wrote:

Hi all,

I have wriiten a function that determines whether tomorrows date is
the first of the month or not then returns a SQL string based on
whether its the first of the month or not.  According to my apache
error logs I get an error that says:

[Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: 
mysql_fetch_array(): supplied argument is not a valid MySQL result

resource in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\validation.php on line 331

I understand that this is a warning but I believe that it has
something to do with the fact that no output is being displayed.  All
other mysql database outputs work fine.

This is the code that sets the query in the mysql_query parameter

$Month_query = mysql_query($this-determineMonth());


Add this after your month_query call:

echo mysql_error() . br/;

It will tell you what's wrong with the query. I'd probably also print 
out the query:


$qry = $this-determineMonth();
echo $qry . br/;

and run it manually (if something does get returned).

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

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



Re: [PHP] mysql_fecth_array() and function call as parameter

2006-03-26 Thread Paul Goepfert
I placed the echo statements in my code and I found out that my query
was empty.  I also went a step further and tested if I was getting the
correct outputs from the queries that initially do at the beginning of
the method.  Instead of getting an output like March I got an output
that says Resource id#9.  I don't get it.  I tested the sql
statement in MySQL that I have on my computer.  It worked,  Why
wouldn't it give the same output through mysql_query()?

Paul

On 3/26/06, Chris [EMAIL PROTECTED] wrote:
 Paul Goepfert wrote:
  Hi all,
 
  I have wriiten a function that determines whether tomorrows date is
  the first of the month or not then returns a SQL string based on
  whether its the first of the month or not.  According to my apache
  error logs I get an error that says:
 
  [Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning:
  mysql_fetch_array(): supplied argument is not a valid MySQL result
  resource in C:\\Program Files\\Apache
  Group\\Apache2\\htdocs\\validation.php on line 331
 
  I understand that this is a warning but I believe that it has
  something to do with the fact that no output is being displayed.  All
  other mysql database outputs work fine.
 
  This is the code that sets the query in the mysql_query parameter
 
  $Month_query = mysql_query($this-determineMonth());

 Add this after your month_query call:

 echo mysql_error() . br/;

 It will tell you what's wrong with the query. I'd probably also print
 out the query:

 $qry = $this-determineMonth();
 echo $qry . br/;

 and run it manually (if something does get returned).

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


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



Re: [PHP] mysql_fecth_array() and function call as parameter

2006-03-26 Thread Chris

Paul Goepfert wrote:

I placed the echo statements in my code and I found out that my query
was empty.  I also went a step further and tested if I was getting the
correct outputs from the queries that initially do at the beginning of
the method.  Instead of getting an output like March I got an output
that says Resource id#9.  I don't get it.  I tested the sql
statement in MySQL that I have on my computer.  It worked,  Why
wouldn't it give the same output through mysql_query()?


Ahh, didn't notice that.


$query1 = mysql_query(SELECT months FROM Month WHERE m_id =
month(curdate()));

$query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum =
day(curdate()));

$query3 = mysql_query(SELECT year FROM Year WHERE year = year(curdate()));


These return result resources (kinda like '$fp = fopen' doesn't return 
the file - it returns a handle only), not the results. You need to do:


$query1_data = mysql_fetch_assoc($query1, 0, 0);

then

switch($query1_data) {

}

see http://www.php.net/mysql_query and 
http://www.php.net/mysql_fetch_assoc for more info.




On 3/26/06, Chris [EMAIL PROTECTED] wrote:


Paul Goepfert wrote:


Hi all,

I have wriiten a function that determines whether tomorrows date is
the first of the month or not then returns a SQL string based on
whether its the first of the month or not.  According to my apache
error logs I get an error that says:

[Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning:
mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\validation.php on line 331

I understand that this is a warning but I believe that it has
something to do with the fact that no output is being displayed.  All
other mysql database outputs work fine.

This is the code that sets the query in the mysql_query parameter

$Month_query = mysql_query($this-determineMonth());


Add this after your month_query call:

echo mysql_error() . br/;

It will tell you what's wrong with the query. I'd probably also print
out the query:

$qry = $this-determineMonth();
echo $qry . br/;

and run it manually (if something does get returned).

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







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

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



Re: [PHP] opening .Z archive with gzopen

2006-03-26 Thread nicolas figaro

Chris a écrit :

nicolas figaro wrote:

Hi

I'm using php 4.3.11 on linux RH9.

I'd like to open a .Z archive with gzopen.
I looked at the options of gzopen, but I'm not sure there is a way to 
specify the compression used by compress/uncompress.


Has anyone ever tried and done this yet ? (without a 
system(uncompress $file)


Since a compressed file isn't the same as a gzipp'ed file I'd guess 
this won't work.


This might:

http://pear.php.net/package/File_Archive

but it doesn't mention .Z files specifically.


Hi and thanks for the answer.

The package contains an uncompress function, but the goal was to open 
the file withuout uncompressing it

(like the zcat command or gzopen function).

Or I can ask the guys who generates .Z files to generate .gz instead.

N F

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